using mblen in windows

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

using mblen in windows

fd fsa
I have set my system locale to Korean in windows.
and in test program

void main()
{
    setlocale(LC_ALL, "korean");

    char *b = "한";
   
    mblen(NULL, MB_CUR_MAX);
    printf("%d\n", mblen(b, MB_CUR_MAX));
    printf("%d\n", strlen(b));       
}

C:\WINDOWS\system32\cmd.exe /c ( ^"mbstrlentest^" )
-1
3
shell returned 2
Hit any key to close this window...

mblen seems to return incorrect multibyte length.  if I set locale to Korean, is it even a multibyte coding? strlen says 3 bytes, so I assume it's multibyte.

------------------------------------------------------------------------------

_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: using mblen in windows

Eli Zaretskii
> From: fd fsa <[hidden email]>
> Date: Mon, 29 Aug 2016 13:01:17 -0400
>
> I have set my system locale to Korean in windows.
> and in test program
>
> void main()
> {
>     setlocale(LC_ALL, "korean");
>
>     char *b = "한";
>
>     mblen(NULL, MB_CUR_MAX);
>     printf("%d\n", mblen(b, MB_CUR_MAX));
>     printf("%d\n", strlen(b));
> }
>
> C:\WINDOWS\system32\cmd.exe /c ( ^"mbstrlentest^" )
> -1
> 3
> shell returned 2
> Hit any key to close this window...
>
> mblen seems to return incorrect multibyte length. if I set locale to Korean, is it even a multibyte coding? strlen
> says 3 bytes, so I assume it's multibyte.

How (in what codepage) did you encode your source file?  AFAIK, the
Korean codepage is 949, where the character you used is a 2-byte
sequence.  That in your case it used 3 bytes makes be suspect your
source file was encoded in UTF-8, which is not supported by Windows
mblen.

------------------------------------------------------------------------------
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: using mblen in windows

fd fsa
My source file is encoded in cp949, then I have to give mingw an option -finput-charset=CP949
so , I guess gcc converts file encoded in cp949 to utf-8.

2016-08-29 13:27 GMT-04:00 Eli Zaretskii <[hidden email]>:
> From: fd fsa <[hidden email]>
> Date: Mon, 29 Aug 2016 13:01:17 -0400
>
> I have set my system locale to Korean in windows.
> and in test program
>
> void main()
> {
>     setlocale(LC_ALL, "korean");
>
>     char *b = "한";
>
>     mblen(NULL, MB_CUR_MAX);
>     printf("%d\n", mblen(b, MB_CUR_MAX));
>     printf("%d\n", strlen(b));
> }
>
> C:\WINDOWS\system32\cmd.exe /c ( ^"mbstrlentest^" )
> -1
> 3
> shell returned 2
> Hit any key to close this window...
>
> mblen seems to return incorrect multibyte length. if I set locale to Korean, is it even a multibyte coding? strlen
> says 3 bytes, so I assume it's multibyte.

How (in what codepage) did you encode your source file?  AFAIK, the
Korean codepage is 949, where the character you used is a 2-byte
sequence.  That in your case it used 3 bytes makes be suspect your
source file was encoded in UTF-8, which is not supported by Windows
mblen.

------------------------------------------------------------------------------
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe


------------------------------------------------------------------------------

_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: using mblen in windows

Eli Zaretskii
> From: fd fsa <[hidden email]>
> Date: Mon, 29 Aug 2016 14:52:16 -0400
>
> My source file is encoded in cp949, then I have to give mingw an option -finput-charset=CP949
> so , I guess gcc converts file encoded in cp949 to utf-8.

Yes.  You need to use -fexec-charset to override the default UTF-8,
AFAIK.

------------------------------------------------------------------------------
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Loading...