• 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: Xcode-users Digest, Vol 7, Issue 153
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Xcode-users Digest, Vol 7, Issue 153


  • Subject: Re: Xcode-users Digest, Vol 7, Issue 153
  • From: Ben Staveley-Taylor <email@hidden>
  • Date: Mon, 12 Apr 2010 11:56:18 +0100

Thanks for the replies.

Paul is right that I am working with inherited wchar_t code in a cross-platform codebase and I want it to work the way it does on Windows. Telling my Windows colleagues to rewrite their code using CFStrings for no functional change is not going to go down too well!

The setlocale() workaround will do me fine for now. Since I don't like to change the environment of the whole app just for this issue I've modified it slightly to use the xlocale explicit locale facility:

	locale_t utf8locale = newlocale(LC_CTYPE_MASK, "UTF-8", NULL);
	int count = swprintf_l(buf, 256, utf8locale, L"Hello \%S World", L"\u3060" );		// 3060 is  a Japanese character
	freelocale(utf8locale);

that seems to work. I am prepared to trust the conversion of wchar_t to UTF8 and back is lossless, though pointless.

I'm still baffled by the need for a locale. I thought the whole point of UTF-32 (which is what wchar_t strings boil down to) was to get rid of locale issues. I think I'll raise a bug on this one.

-- Ben.



On 10 Apr 2010, at 15:02, email@hidden wrote:

> Date: Fri, 9 Apr 2010 21:17:52 +0100
> From: "Paul Sanders" <email@hidden>
>
> Wide string to multibyte character conversions going on behind your back is the last thing you want from swprintf.  It should be wchar_t transparent when processing wide strings and wide characters, but it isn't.  That's why I abandoned it, a decision which has served me well.
>
> I think the OP and I both have existing code, based on wide strings, which we want to reuse.  swprintf, as implemented by glibc, gets in the way of that.  The discussion about cross-platform strings in the referenced thread rather misses the point.
>
> Paul Sanders.
>
> ----- Original Message -----
> From: "Dan Korn" <email@hidden>
> Sent: Friday, April 09, 2010 8:50 PM
>
>
> Take a look at this thread:
> http://lists.apple.com/archives/carbon-dev/2007/May/msg00575.html
>
> Specifically, from this post forward:
> http://lists.apple.com/archives/carbon-dev/2007/May/msg00585.html
>
> Dan

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Xcode-users Digest, Vol 7, Issue 153
      • From: Chris Espinosa <email@hidden>
  • Prev by Date: .png images getting corrupted?
  • Next by Date: Re: .png images getting corrupted?
  • Previous by thread: Re: .png images getting corrupted?
  • Next by thread: Re: Xcode-users Digest, Vol 7, Issue 153
  • Index(es):
    • Date
    • Thread