• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Init an NSString
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Init an NSString


  • Subject: Init an NSString
  • From: email@hidden
  • Date: Thu, 19 Dec 2002 17:45:25 -0800 (PST)

Hello!

I'm still in the steep part of Obj-C learning curve,
but it starts to yield results.

I have a small problem right now.
I want to test whether a string S starts with
a given prefix.

If I do:
NSString * Prefix = @"####";
BOOL result = [S hasPrefix:Prefix];

I get the right result.

The problem comes when I want to use a
non-ASCII prefix. I have tried the same with
a sequence of japanese question marks :????.
(I wrote them in ASCII here so that you can read
the mail, but these are Unicode values).

When I use the Japanese input interface in the
source code, the first time, I was asked something
like:
"You are about to enter non-ascii codes in your
source. What do you want to do?"
And there were 2 options.
- Promote to UTF-8
- Keep as is (as far as I remember).

I choosed to promote my code to UTF-8. That's
what I always do in BeOS which works in UTF-8
by default and I can initialize strings with Japanese
characters like:
char * string = "Some Japanese text";

Now, when I am trying to run this code, it
simply does not work.
In the debugger, I can see the string I am testing,
(the one I read from a file) which is displayed
correctly in the variables area.
But the prefix displays garbage characters.
The UTF-8 ???? are replaced with 4 times 3 chars.
Something like a&#a&#a&#a&#.

Result: I cannot detect what I want.

Well, there is a workaround; read the prefix
from a file. But how could I initialize the
prefix statically?

Thanks!

Pascal
_______________________________________________
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.

  • Prev by Date: Re: Dock menu
  • Next by Date: Re: Why is this code leaking memory?
  • Previous by thread: Re: Finding Applications for File Type
  • Next by thread: Re: Init an NSString
  • Index(es):
    • Date
    • Thread