How to construct Unicode Safe Strings in the source?
How to construct Unicode Safe Strings in the source?
- Subject: How to construct Unicode Safe Strings in the source?
- From: Martin Häcker <email@hidden>
- Date: Sun, 13 Jul 2003 02:48:23 +0200
Hi there,
well right now I am totally stumped. I just don't know what to make of this.
Today I created two new projects (both in Xcode)
and tried to play a bit with utf8-strings.
Because the @"" constructor doesnt directly
support unicode I tried to get around this
somehow.
But this is where the trouble starts. In the one
project this works to get correct utf8-strings:
--- snip ----
char * aCString = "Keld Jxrn Simonsen";
[[NSString alloc] initWithFormat:@"%s", aCString];
--- snap ---
While in the other I have to do this:
--- snip ---
char * aCString = "Keld Jxrn Simonsen";
id data = [NSData dataWithBytesNoCopy: aCString
length: strlen(aCString) freeWhenDone: NO];
id string = [[NSString alloc] initWithData: data
encoding NSUTF8StringEncoding];
--- snap ---
Now what really mystifies me is that each of this
methods to get strings with the correct content
_doesn't_ work in the other project! (Though I
created them both by myself and today). The only
difference being that the one is a foundation
tool, while the other is a GUI app. File
encodings are the same (utf8) in both cases, so
thats out.
Now before I spend countless hours on this...
Does anybody know whats going on here?
I'd like to try to get an easy way to construct
unicode strings on the fly (for unit-testing)
without loading them from a file or somewhere
else, so I'm somewhat interested in this topic...
:)
Thanks in advance for every answer!
cu Martin
--
dont.wanna.tell
[ot]coder - hehe
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.