• 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: iconv (libiconv.dylib) broken
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: iconv (libiconv.dylib) broken


  • Subject: Re: iconv (libiconv.dylib) broken
  • From: Jonas Maebe <email@hidden>
  • Date: Tue, 9 Feb 2010 23:24:27 +0100

On 09 Feb 2010, at 22:52, Andreas Grosam wrote:

> On Feb 9, 2010, at 9:50 PM, Jonas Maebe wrote:
>
>>
>> On 09 Feb 2010, at 20:58, Andreas Grosam wrote:
>>
>>> after experimenting with the iconv library it seems that it is broken on Mac OS X.
>>
>> It works fine, but but you have to call setlocale(LC_ALL,"") before calling any iconv routines.
> Unfortunately, this does not work for me.
> setlocale(LC_ALL,"") will set the global  "C" locale on my system, since the corresponding environment variables (LC_* and LANG) are not set.

Are you perhaps on 10.5? It works for me on 10.6 if I include the setlocale call, even with a C locale (including explicitly setting LC_TYPE to C, as it's set to UTF-8 even if you export LANG=C). On 10.5, it indeed only works if the locale is UTF-8 (or if you explicitly pass an UTF-8 locale as second argument to setlocale, such as en_US.UTF-8).

I've included my modified version of your program below. If I comment out the setlocale call, it fails. With the call, it works (on 10.6, or on 10.5 with an UTF-8 locale -- and it always works on both if I pass "en_US.UTF-8" as second parameters to setlocale).

> Anyway, the POSIX global locale shouldn't have any effect in iconv. Iconv converts character strings from one specified locale to another specified locale and is thus independent on the POSIX locale which is always global for the process.


You're right. I was misremembering the situation in which I ran into a similar problem (in which case I was calling nl_langinfo to determine the target locale for iconv calls, where you do have to call setlocale first since otherwise nl_langinfo may simply return info about the C locale)

> I should also mention, that I convert from the "WCHAR_T" locale to "UTF-8", in which case the conversion fails.

It seems that this conversion is somehow bound to setlocale, even though it indeed shouldn't be.


Jonas _______________________________________________
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: iconv (libiconv.dylib) broken
      • From: Andreas Grosam <email@hidden>
References: 
 >iconv (libiconv.dylib) broken (From: Andreas Grosam <email@hidden>)
 >Re: iconv (libiconv.dylib) broken (From: Jonas Maebe <email@hidden>)
 >Re: iconv (libiconv.dylib) broken (From: Andreas Grosam <email@hidden>)

  • Prev by Date: Re: iconv (libiconv.dylib) broken
  • Next by Date: Re: iconv (libiconv.dylib) broken
  • Previous by thread: Re: iconv (libiconv.dylib) broken
  • Next by thread: Re: iconv (libiconv.dylib) broken
  • Index(es):
    • Date
    • Thread