diff --git a/regress/lib/libc/mbstowcs/Makefile b/regress/lib/libc/mbstowcs/Makefile new file mode 100644 index 000000000000..663db4507539 --- /dev/null +++ b/regress/lib/libc/mbstowcs/Makefile @@ -0,0 +1,17 @@ +# $NetBSD: Makefile,v 1.1 2004/02/26 23:29:46 itojun Exp $ + +NOMAN= # defined + +PROG= mbtest + +regress: ${PROG} + LC_CTYPE=ja_JP.eucJP LANG= ./${PROG} < ${.CURDIR}/euc-jp.txt \ + | diff ${.CURDIR}/euc-jp.output - + LC_CTYPE=ja_JP.SJIS LANG= ./${PROG} < ${.CURDIR}/sjis.txt \ + | diff ${.CURDIR}/sjis.output - + LC_CTYPE=ja_JP.ISO2022-JP LANG= ./${PROG} < ${.CURDIR}/iso-2022-jp.txt \ + | diff ${.CURDIR}/iso-2022-jp.output - + LC_CTYPE=en_US.UTF-8 LANG= ./${PROG} < ${.CURDIR}/utf8.txt \ + | diff ${.CURDIR}/utf8.output - + +.include diff --git a/regress/lib/libc/mbstowcs/euc-jp.output b/regress/lib/libc/mbstowcs/euc-jp.output new file mode 100644 index 000000000000..39db11be3979 --- /dev/null +++ b/regress/lib/libc/mbstowcs/euc-jp.output @@ -0,0 +1,7 @@ +setlocale = ja_JP.eucJP +」ナ」ユ」テ、ヌ、ケ。」aaaa、「、、、ヲ、ィ、ェ + +0xA3C5 0xA3D5 0xA3C3 0xA4C7 0xA4B9 0xA1A3 0x0061 0x0061 0x0061 0x0061 0xA4A2 0xA4A4 0xA4A6 0xA4A8 0xA4AA 0x000A +width: +2 2 2 2 2 2 1 1 1 1 2 2 2 2 2 0 +wcswidth=26 diff --git a/regress/lib/libc/mbstowcs/euc-jp.txt b/regress/lib/libc/mbstowcs/euc-jp.txt new file mode 100644 index 000000000000..327d45ded877 --- /dev/null +++ b/regress/lib/libc/mbstowcs/euc-jp.txt @@ -0,0 +1 @@ +」ナ」ユ」テ、ヌ、ケ。」aaaa、「、、、ヲ、ィ、ェ diff --git a/regress/lib/libc/mbstowcs/iso-2022-jp.output b/regress/lib/libc/mbstowcs/iso-2022-jp.output new file mode 100644 index 000000000000..a9e0e1b39f2d --- /dev/null +++ b/regress/lib/libc/mbstowcs/iso-2022-jp.output @@ -0,0 +1,7 @@ +setlocale = ja_JP.ISO2022-JP +$B#J#I#S$G$9!#(Baaaa$B$"$$$&$($*(B + +0x4200234A 0x42002349 0x42002353 0x42002447 0x42002439 0x42002123 0x0061 0x0061 0x0061 0x0061 0x42002422 0x42002424 0x42002426 0x42002428 0x4200242A 0x000A +width: +2 2 2 2 2 2 1 1 1 1 2 2 2 2 2 0 +wcswidth=26 diff --git a/regress/lib/libc/mbstowcs/iso-2022-jp.txt b/regress/lib/libc/mbstowcs/iso-2022-jp.txt new file mode 100644 index 000000000000..7ac4fea338e1 --- /dev/null +++ b/regress/lib/libc/mbstowcs/iso-2022-jp.txt @@ -0,0 +1 @@ +$B#J#I#S$G$9!#(Baaaa$B$"$$$&$($*(B diff --git a/regress/lib/libc/mbstowcs/mbtest.c b/regress/lib/libc/mbstowcs/mbtest.c new file mode 100644 index 000000000000..7879f37a85b2 --- /dev/null +++ b/regress/lib/libc/mbstowcs/mbtest.c @@ -0,0 +1,71 @@ +/* $NetBSD: mbtest.c,v 1.1 2004/02/26 23:29:46 itojun Exp $ */ +/*- + * Copyright (c) 1999 Citrus Project, + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include +#include + +int +main(int ac, char **av) +{ + char buf[256]; + char *str; + int c; + wchar_t wbuf[256]; + wchar_t *p; + + printf("setlocale = %s\n", setlocale(LC_CTYPE, "")); + + for (str = buf; 1; str++) { + c = getchar(); + if (c == EOF || c == '\n') + break; + *str=c; + } + *str='\0'; + strcat(buf, "\n"); + + mbstowcs(wbuf, buf, sizeof(buf) - 1); + wcstombs(buf, wbuf, sizeof(buf) - 1); + printf("%s\n", buf); + + for (p = wbuf; *p; p++) { + printf("0x%04X ", (unsigned)*p); + } + putchar('\n'); + + printf("width:\n", buf); + for (p=wbuf; *p; p++) { + printf("%d ", wcwidth(*p)); + } + putchar('\n'); + + printf("wcswidth=%d\n", wcswidth(wbuf, sizeof(wbuf) - 1)); + + return 0; +} diff --git a/regress/lib/libc/mbstowcs/sjis.output b/regress/lib/libc/mbstowcs/sjis.output new file mode 100644 index 000000000000..69e46f6046e4 --- /dev/null +++ b/regress/lib/libc/mbstowcs/sjis.output @@ -0,0 +1,7 @@ +setlocale = ja_JP.SJIS +SJISです。aaaaあいうえお + +0x8272 0x8269 0x8268 0x8272 0x82C5 0x82B7 0x8142 0x0061 0x0061 0x0061 0x0061 0x82A0 0x82A2 0x82A4 0x82A6 0x82A8 0x000A +width: +2 2 2 2 2 2 2 1 1 1 1 2 2 2 2 2 0 +wcswidth=28 diff --git a/regress/lib/libc/mbstowcs/sjis.txt b/regress/lib/libc/mbstowcs/sjis.txt new file mode 100644 index 000000000000..d7d7f8295a9f --- /dev/null +++ b/regress/lib/libc/mbstowcs/sjis.txt @@ -0,0 +1 @@ +SJISです。aaaaあいうえお diff --git a/regress/lib/libc/mbstowcs/utf2.txt b/regress/lib/libc/mbstowcs/utf2.txt new file mode 100644 index 000000000000..503819785197 --- /dev/null +++ b/regress/lib/libc/mbstowcs/utf2.txt @@ -0,0 +1 @@ +[][ツ゚ソ][燿ソソ][逗ソソソ][ソソソソ][оソソソソソ] diff --git a/regress/lib/libc/mbstowcs/utf8.output b/regress/lib/libc/mbstowcs/utf8.output new file mode 100644 index 000000000000..17ac5fd102a7 --- /dev/null +++ b/regress/lib/libc/mbstowcs/utf8.output @@ -0,0 +1,7 @@ +setlocale = en_US.UTF-8 +[][ツ゚ソ][燿ソソ][逗ソソソ][ソソソソ][оソソソソソ] + +0x005B 0x0001 0x007F 0x005D 0x005B 0x0080 0x07FF 0x005D 0x005B 0x0800 0xFFFF 0x005D 0x005B 0x10000 0x1FFFFF 0x005D 0x005B 0x200000 0x3FFFFFF 0x005D 0x005B 0x4000000 0x7FFFFFFF 0x005D 0x000A +width: +1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 0 +wcswidth=12 diff --git a/regress/lib/libc/mbstowcs/utf8.txt b/regress/lib/libc/mbstowcs/utf8.txt new file mode 100644 index 000000000000..503819785197 --- /dev/null +++ b/regress/lib/libc/mbstowcs/utf8.txt @@ -0,0 +1 @@ +[][ツ゚ソ][燿ソソ][逗ソソソ][ソソソソ][оソソソソソ]