Re: C++ string and UTF8
Re: C++ string and UTF8
- Subject: Re: C++ string and UTF8
- From: Will Mason <email@hidden>
- Date: Wed, 6 Apr 2005 23:34:29 -0700 (PDT)
- Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
C++ string objects can't contain UTF-16 characters, since each element
is only one byte long. C++ string consists of chars and C++ wstring
consits of wchar_ts, the encoding of which is almost impossible to
know.
If you use [NSString stringWithUTF8String:], you run a very good chance
of getting back a usable string, but you have no way of knowing the
encoding used by the C++ string unless you kept track of it yourself.
So, I would say that you will probably be able to count on [NSString
stringWithUTF8String:] doing the right thing, but you can't know.
Good luck,
Will
--- Julien Palmas <email@hidden> wrote:
> And what if the c++ string contains Unicode (UTF-16), and not UTF-8 ?
> This time it looks like I can't use c_str() ...
>
> On Apr 7, 2005, at 10:57 AM, Julien Palmas wrote:
>
> > well, it looks you are right.
> >
> > Thanks.
> >
> > On Apr 7, 2005, at 10:31 AM, daniel wrote:
> >
> >> Is it true that the c_str will "de-UTF8" a C++ string's
> characters?
> >> I'm guessing it probably doesn't, and you can use it combined with
>
> >> NSString "stringWithUTF8String" convenience method to make the
> >> conversion you require.
> >>
> >> Daniel
> >>
> >> On Apr 6, 2005, at 5:48 PM, Julien Palmas wrote:
> >>
> >>> I have a c++ string containing UTF8 data.
> >>> I would like to make a NSString out of it.
> >>> Obviously, the c_str() method will not work as I will lose all
> the
> >>> non ascii characters.
> >>
> >
> > _______________________________________________
> > Do not post admin requests to the list. They will be ignored.
> > Cocoa-dev mailing list (email@hidden)
> > Help/Unsubscribe/Update your Subscription:
> > email@hidden
> >
> > This email sent to email@hidden
> >
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
>
> This email sent to email@hidden
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden