• 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
Re: String encoding problem (WSMethodInvocation)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: String encoding problem (WSMethodInvocation)


  • Subject: Re: String encoding problem (WSMethodInvocation)
  • From: Ricky Sharp <email@hidden>
  • Date: Thu, 24 Jan 2008 16:11:18 -0600


On Jan 24, 2008, at 10:37 AM, Jeremy Pereira wrote:


On 24 Jan 2008, at 14:02, Nick Toumpelis wrote:

Hi all,

I'm stuck with a curious string encoding problem.

I start with a string in Greek, which is stored using Core Data (an entity with a String property). Later in the execution, I get this string, add it to an NSMutableDictionary which is sent as a callParams argument in WSMethodInvocationSetParameters - as part of a method invocation sent to an XML-RPC web service.

As far as I can tell, nothing changes in the string encoding prior to the method invocation. When I print out the string with NSLog, the result is in Greek. Using the print-object command in gdb, I get this: "\U039b\U03b1\U03bb\U03b1".

Remotely, the string is not stored properly. The stored value is ???? and that's what I get, when I ask the web service for the same string. However, using another Mac application, the web service gets the string properly.

I assume that the method invocation dispatches something that is not a properly formatted UTF-8 string. I might be wrong.

Maybe the string is being encoded as UTF-16 and you have an endian problem. Is your Mac PPC and your web service on an Intel machine, or vice versa?


The string is most likely being transported out by you as UTF-8. Had it gone out UTF-16 and ended up with an Endian issue, you would most likely not get '?' characters. For example 0x039B would be 0x9B03 which is a Chinese character.

Anyhow, the '?' is typically used in cases where a character conversion proves lossy (e.g. UTF-8 to ISO_8859-1). Since a ton of web stuff is (unfortunately) still hard-wired to ISO_8859-1, that's my guess as to what's going on.

The way to troubleshoot this is divide-and-conquer. You have to look at every location of I/O code (e.g. file I/O) and look at what encodings are used to propagate your data. The really tricky part comes in when written codes uses implicit default encodings. On a Windows machine, this will be CP1252 (very close to ISO_8859-1). Many APIs unfortunately do not take explicit encoding parameters. You thus end up with the default encoding for a particular platform/service/etc.

Another thing to check is if the web service can accept an encoding parameter (hopefully it does). It may then be the case where it's too picky as to spelling? For example, would "UTF-8", "utf8", etc. all work? Or, does it want an "official" charset name? I believe the official names are identified at iana.org.


___________________________________________________________ Ricky A. Sharp mailto:email@hidden Instant Interactive(tm) http://www.instantinteractive.com

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >String encoding problem (WSMethodInvocation) (From: Nick Toumpelis <email@hidden>)
 >Re: String encoding problem (WSMethodInvocation) (From: Jeremy Pereira <email@hidden>)

  • Prev by Date: Re: Nib ownership and retain count
  • Next by Date: Re: NSPredicateEditor
  • Previous by thread: Re: String encoding problem (WSMethodInvocation)
  • Next by thread: Re: String encoding problem (WSMethodInvocation)
  • Index(es):
    • Date
    • Thread