Owner
2/11/2011 12:42:00 AM
On Thu, 10 Feb 2011 19:37:57 -0500, Owner wrote:
> On Thu, 10 Feb 2011 15:52:49 -0800, Keith Thompson wrote:
>
>> Owner <Owner@Owner-PC.com> writes:
>>> On Thu, 10 Feb 2011 07:21:54 -0500, Owner wrote:
>>>> what's wrong with this code?
>>>>
>>>> #include <locale.h>
>>>> #include <stdio.h>
>>>> #include <wchar.h>
>>>>
>>>> main(){
>>>> setlocale(LC_CTYPE, "");
>>>> wchar_t a = L'CN';
>>>> putwchar(a);
>>>>
>>>> }
>>>>
>>>> result
>>>>
>>>> test.c:7: warning: multi-character character constant
>>>
>>> Strangely this below code works then.
>>>
>>> #include <locale.h>
>>> #include <stdio.h>
>>> #include <wchar.h>
>>>
>>>
>>> main(){
>>> wchar_t *a = L"CN±U";
>>> setlocale(LC_ALL, "ko");
>>>
>>> wprintf(L"%s",a);
>>>
>>> }
>>
>> Well, at least the compiler isn't going to warn about the second
>> case; you're using a string literal rather than a character constant,
>> so you can have as many characters/bytes/glyphs between them as
>> you like.
>>
>> What does wcslen(a) return?
4
>>
>> (Note that, in my newsreader, your string literal looks something like
>> L"[][]"
>> only fuzzier.)
supposed to be korean in 2 letters
>
> Solved!
>
> downloaded visual c++ express 2010 and compiled below code
> with cl.exe and worked.
>
> #include <locale.h>
> #include <stdio.h>
> #include <wchar.h>
>
>
> main(){
> wchar_t a = L'CN';
> setlocale(LC_ALL, "kor");
>
> putwchar(a);
>
> }