From: Mirek Fidler on
> Having said that, I think a lot depends on the application. I
> certainly wouldn't like to have to write an editor using UTF-8,
> for example.

Actually, as I have some experience in this field, it is less
complicated that it seems - if you consider implementation using UTF-8
to storing "document" data and "unpack"/"pack" them as needed

E.g. for line oriented editor it is easy and efficient to store main
document as array of utf-8 strings and convert from utf-8 to wide string
just the line you need, modify and convert back to utf-8. Other editor
operations are much more expensive than that....

Mirek

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: Valentin Samko on
Alf P. Steinbach wrote:
> * Pete Becker:
>> Wu Yongwei wrote:
>>
>>> A gotcha under Windows: wchar_t is 2 bytes wide.
>> wchar_t is a type defined by the compiler. For some Windows compilers
>> it's 2 bytes wide, for others it isn't.
>
> Is there a C++ compiler for 32-bit Windows where wchar_t isn't 32 bits
> by default?

The right question is "Is there a C++ compiler for Windows where wchar_t IS 32 bits?" .

With Comeau, g++, VC++, Intel C++ sizeof(wchar_t) is 2 on Windows.

> If such a compiler exists it would be unable to compile existing source
> code based on the identity assumption C++ wchar_t === Windows WCHAR.
the size of WCHAR is 2 bytes.

--

Valentin Samko - http://www.valentinsamko.com

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: Pete Becker on
kanze wrote:

>
> Is that true? I'm not that familiar with the Windows world, but
> I know that a compiler for a given platform doesn't have
> unlimited freedom. At the very least, it must be compatible
> with the system API. (Not according to the standard, of course,
> but practically, to be usable.) And I was under the impression
> that the Windows API (unlike Unix) used wchar_t in some places.
>

The Windows API uses WCHAR, which is a macro or a typedef (haven't
looked it up recently) for a suitably sized integer type.

--

Pete Becker
Roundhouse Consulting, Ltd.

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: Nemanja Trifunovic on

Dave wrote:
> A few weeks ago I looked for an implementation of std::string that can
> handle UTF8 strings. I was thinking that the STL iterator abstraction
> would be nice for iterating over a variable length encoded string. So
> far I haven't found anything. Does anybody know of a UTF8 std::string
> implementation?

In general, there is nothing wrong with keeping utf-8 strings in
std::string objects, as long as you know what you are doing.

Although, I prefer std::vector<unsigned char> for that purpose.


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: Maxim Yegorushkin on

Alf P. Steinbach wrote:
> * Pete Becker:
> > Wu Yongwei wrote:
> >
> >> A gotcha under Windows: wchar_t is 2 bytes wide.
> >
> > wchar_t is a type defined by the compiler. For some Windows compilers
> > it's 2 bytes wide, for others it isn't.
>
> Is there a C++ compiler for 32-bit Windows where wchar_t isn't 32 bits
> by default?

Is not 2 == sizeof(wchar_t) true for all M$ compilers for win32?


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13
Prev: localtime deprecated?
Next: bind guard ?