regress for mbstowcs/wcstombs. from citrus distribution
This commit is contained in:
parent
810f44f51e
commit
0ba94afa3a
|
@ -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 <bsd.prog.mk>
|
|
@ -0,0 +1,7 @@
|
|||
setlocale = ja_JP.eucJP
|
||||
EUCです。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
|
|
@ -0,0 +1 @@
|
|||
EUCです。aaaaあいうえお
|
|
@ -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
|
|
@ -0,0 +1 @@
|
|||
$B#J#I#S$G$9!#(Baaaa$B$"$$$&$($*(B
|
|
@ -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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <locale.h>
|
||||
#include <wchar.h>
|
||||
|
||||
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;
|
||||
}
|
|
@ -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
|
|
@ -0,0 +1 @@
|
|||
SJISです。aaaaあいうえお
|
|
@ -0,0 +1 @@
|
|||
[][б─ъ©][Ю═─О©©][П░──В©©©][Ь┬───Ш©©©©][Э└────Щ©©©©©]
|
|
@ -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
|
|
@ -0,0 +1 @@
|
|||
[][б─ъ©][Ю═─О©©][П░──В©©©][Ь┬───Ш©©©©][Э└────Щ©©©©©]
|
Loading…
Reference in New Issue