Standard C Language Internationalization Programming
Wide Character

Language C provides the following two mechanisms to handle natural languages that require more than 1 byte to represent a character:

Usage of wide characters is recommended in Internationalization Programming. Note that message handling is processed based on multibyte characters so you should choose either of the mechanisms on a case to case basis.

The following are the standard C library functions related to wide character:

--------------------------------------------------------------------------------------------------
Function	Description
--------------------------------------------------------------------------------------------------
mbrtowc()	Converts a multibyte character to a wide character (restartable)
mbtowc()	Converts a multibyte character to a wide character
wcrtomb()	Converts a wide character to a multibyte character (restartable)
wctomb()	Converts a wide character to a multibyte character
mbsrtowcs()	Converts a multibyte string to a wide character string (restartable)	
mbstowcs() 	Converts a multibyte string to a wide character	string 
wcsrtombs() 	Converts a wide character string to a multibyte	string (restartable) 
wcstombs() 	Converts a wide character string to a multibyte string 
wcscat() 	Concatenates two wide character strings
wcsncat()	Concatenates two wide character strings 
wcscpy() 	Copies a wide character string 
wcsncpy() 	Copies a wide character string 
wcscmp()        Compares two wide character strings 
wcsncmp() 	Compares two wide character strings 
wcscoll() 	Compares two wide character strings with collation information	
wcsxfrm() 	Transforms a wide character string for string collation
wcschr()	Searches a wide character in a wide character string
wcsrchr()	Searches a wide character backward in a wide character string 
wcspbrk() 	Searches a wide character string from a set of wide characters 
wcsstr() 	Locates a substring in a wide character string 
wcstok() 	Splits a wide character string into tokens 
wcsspn() 	Counts the wide characters including the specified ones from beginning
wcscspn() 	Counts the wide characters excluding the specified ones from beginning
wcstod() 	Converts a wide character string to a double precision number 
wcstol() 	Converts a wide character string to a long integer 
wcstoul()	Converts a wide character string to an unsigned long integer
wcsftime()	Converts date and time to a wide character string	
wcslen() 	Calculates the length of a wide character string
iswalnum()	Tests for alphanumeric wide character 
iswalpha() 	Tests for alphabetic wide character 
iswcntrl() 	Tests for control wide character
iswdigit() 	Tests for decimal digit wide character 
iswgraph() 	Tests for graphic wide character 
iswlower() 	Tests for lowercase wide character 
iswprint() 	Tests for printing wide character	
iswpunct() 	Tests for punctuation or symbolic wide character 
iswspace() 	Tests for whitespace wide character 
iswupper() 	Tests for uppercase wide character 
iswxdigit() 	Tests for hexadecimal wide character	
wctype() 	Classifies a wide character
iswctype()	Classifies a wide character 
towupper()	Converts a wide character to uppercase
towlower()	Converts a wide character to lowercase 
wctrans() 	Wide character translation mapping 
towctrans() 	Wide character transliteration 
wmemchr()	Searches a wide character in a wide character array 
wmemcmp() 	Compares two arrays of wide characters
wmemcpy()	Copies an array of wide characters 
wmemmove() 	Copies an array of wide characters 
wmemset() 	Fills an array of wide characters with a constant wide character 
fgetwc() 	Reads a wide character from a stream 
getwc() 	Reads a wide character from a stream
getwchar()	Reads a wide character from the standard input		
fgetws() 	Reads a wide character string from a stream 
ungetwc() 	Pushes back a wide character into a stream 
fputwc() 	Writes a wide character to a stream 
putwc() 	Writes a wide character to a stream 
putwchar() 	Writes a wide character to the standard output 
fputws() 	Writes a wide character string to a stream 
fwscanf() 	Reads and converts data	with a wide character format string 
swscanf()	Reads and converts data with a wide character format string
wscanf()	Reads and converts data with a wide character format string	
fwprintf() 	Converts and writes data with a wide character format string 
swprintf() 	Converts and writes data with a wide character format string 
vfwprintf()     Converts and writes data with a wide character format string 
vswprintf() 	Converts and writes data with a	wide character format string 
vwprintf() 	Converts and writes data with a wide character format string 
wprintf() 	Converts and writes data with a wide character format string 
fwide() 	Sets and determines the orientation of a stream 
wcswcs() 	Finds a wide substring 
wcwidth() 	Determines the columns needed for a wide character 
wcswidth() 	Determines the columns needed for a wide character string
--------------------------------------------------------------------------------------------------
The following are the standard C library functions related to multibyte character:
-------------------------------------------------------------------------------------
Function     Description
-------------------------------------------------------------------------------------
mbrlen()     Counts the number of bytes in the next multibyte character (restartable) 
mblen()      Counts number of bytes in the next multibyte character
mbsinit()    Tests for initial shift state
-------------------------------------------------------------------------------------
The following are the mappings of wide character functions and non-wide character functions provided by the standard C library:
---------------------------------------
Non-wide character     Wide character
function	       function
---------------------------------------
isalnum()	       iswalnum()
isalpha()	       iswalpha()
iscntrl()	       iswcntrl()
isdigit()	       iswdigit()
isgraph()	       iswgraph()
islower()	       iswlower()
isprint()	       iswprint()
ispunct()	       iswpunct()
isspace()	       iswspace()
isupper()	       iswupper()
isxdigit()	       iswxdigit()
tolower()	       towlower()
toupper()	       towupper()
fprintf()	       fwprintf()
fscanf()	       fwscanf()
printf()	       wprintf()   *1)
scanf()		       wscanf()
sprintf()	       swprintf()
sscanf()	       swscanf()
vfprintf()	       vwfprintf()
vprintf()	       vwprintf()
vsprintf()	       vswprintf()
fgetc()		       fgetwc()
fgets()		       fgetws()
fputc()		       fputwc()
fputs()		       fputws()
getc()	               getwc()
getchar()	       getwchar()
gets()		       fgetws()
putc()		       putwc()
puts()		       fputws()
putchar()	       putwchar()
ungetc()	       ungetwc()
strtod()	       wcstod()
strtol()	       wcstol()
strtoul()	       wcstoul()
memcpy()	       wmemcpy()
memmove()	       wmemmove()
strcpy()	       wcscpy()
strncpy()	       wcsncpy()
strncat()	       wcsncat()
strcat()	       wcscat()
memcmp()	       wmemcmp()
strcmp()	       wcscmp()
strcoll()	       wcscoll()
strncmp()	       wcsncmp()
strxfrm()	       wcsxfrm()
memchr()	       wmemchr()
strchr()	       wcschr()
strcspn()	       wcscspn()
strpbrk()	       wcspbrk()
strrchr()	       wcsrchr()
strspn()	       wcsspn()
strstr()	       wcsstr()
strtok()	       wcstok()
memset()	       wmemset()
strlen()	       wcslen()
strftime()	       wcsftime()
---------------------------------------
Note that the following wide character functions are deprecated. Use the alternate functions respectively.
------------------------------------------
Deprecated wide	       Recommended wide
character function     character function
------------------------------------------
btowc()		       mbtowc()
wctob()		       wctomb()
------------------------------------------
*1)'printf' can cover wide characters with proper conversion characters ("%ls").

Go to Internationalization Programming Top


Copyright (C) 2012 Kokusaika JP, Inc.
All rights reserved. No reproduction or republication without written permission.