Re: printf functions fail with non-ascii characters
Re: printf functions fail with non-ascii characters
- Subject: Re: printf functions fail with non-ascii characters
- From: "Kyle Sluder" <email@hidden>
- Date: Wed, 5 Sep 2007 14:06:05 -0400
Straight from the printf(3) man page:
``The printf family of functions do not correctly handle multibyte
characters in the format argument.''
So, you have to use something else.
--Kyle Sluder
On 9/5/07, William H. Schultz <email@hidden> wrote:
> I forgot the clarification that the same error occurs when the string
> is passed from the user interface or read from a binary file. In the
> actual code, the characters are displaying correctly in the user
> interface, but the printf function calls with the same data source fail.
>
> For the record, the source code is UTF-8, no BOM.
>
>
> -------------------------------
> Hank Schultz
> Cedrus Corporation
> http://www.cedrus.com/
>
>
> On Sep 5, 2007, at 10:49 AM, Shawn Erickson wrote:
>
> > On 9/5/07, William H. Schultz <email@hidden> wrote:
> >> I might be asking a silly question here, but I've been working
> >> with this
> >> for a few days, and I've narrowed my issues down to this:
> >>
> >> The wide character versions of the printf functions are failing
> >> with various
> >> non-ascii characters, as can be seen with the following code:
> >>
> >>
> >>
> >> #include <stdarg.h>
> >> #include <wchar.h>
> >>
> >> int main()
> >> {
> >> wchar_t buf[20];
> >> va_list ap;
> >> return vswprintf(buf, 20, L"トネヘ", ap);
> >> }
> >>
> >> In case the above doesn't properly survive the e-mail, that's just
> >> three
> >> random Japanese characters in the test string. This code returns
> >> -1 instead
> >> of the 3 that I would expect by looking at it. The same is true
> >> for various
> >> other sets of non-ascii characters and various other wide
> >> character printf
> >> functions.
> >>
> >> I'm using Xcode 2.4.1 under 10.4.10 on an Intel machine. This is
> >> with g++
> >> version 4.0.1 (build 5367).
> >>
> >> Any ideas?
> >
> > What encoding are using using for the file that contains main? Using
> > mulit-byte characters directly in source code is fragile and not
> > always supported.
> >
> > -Shawn
>
>
> _______________________________________________
> 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
>
>
_______________________________________________
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