[PATCH] codecvt<wchar_t, char, mbstate_t> support for UTF-8, take 2

Pétur Runólfsson peturr02@ru.is
Tue Jan 28 13:49:00 GMT 2003


Hi again,

This patch adds support for UTF-8 locales to
codecvt<wchar_t, char, mbstate_t>::do_encoding, do_in, and do_max_length.

do_in now performs the conversion with mbrtowc. This is of course not
thread-safe (except in the gnu version) and is probably not very efficient
either (equivalent of a virtual function call for each character converted)
but seems to be the only way to implement this as the input sequence for
do_in is in general not zero-terminated.

Any comments?

Petur


2003-01-28  Petur Runolfsson  <peturr02@ru.is>

	* src/codecvt.cc
	(codecvt<wchar_t, char, mbstate_t>::do_encoding, do_max_length):
	Use MB_CUR_MAX and move...
	* config/locale/generic/codecvt_members.cc:  ...here.
	* config/locale/gnu/codecvt_members.cc:  ...and here.
	* config/locale/generic/codecvt_members.cc,
	* config/locale/gnu/codecvt_members.cc
	(codecvt<wchar_t, char, mbstate_t>::do_in):  Perform
	conversion with mbrtowc and an explicit loop rather than
	mbsrtowcs.
	* testsuite/22_locale/codecvt/encoding/wchar_t/1.cc:
	Cleanup and check for correct return value from encoding
	for "C" locale.
	* testsuite/22_locale/codecvt/encoding/wchar_t/2.cc:  New test.
	* testsuite/22_locale/codecvt/encoding/wchar_t/3.cc:  New test.
	* testsuite/22_locale/codecvt/encoding/wchar_t/4.cc:  New test.
	* testsuite/22_locale/codecvt/in/wchar_t/1.cc:  Cleanup.
	* testsuite/22_locale/codecvt/in/wchar_t/2.cc:  New test.
	* testsuite/22_locale/codecvt/in/wchar_t/3.cc:  New test.
	* testsuite/22_locale/codecvt/in/wchar_t/4.cc:  New test.
	* testsuite/22_locale/codecvt/in/wchar_t/5.cc:  New test.
	* testsuite/22_locale/codecvt/in/wchar_t/6.cc:  New test.
	* testsuite/22_locale/codecvt/in/wchar_t/7.cc:  New test.
	* testsuite/22_locale/codecvt/in/wchar_t/8.cc:  New test.
	* testsuite/22_locale/codecvt/in/wchar_t/9.cc:  New test.
	* testsuite/22_locale/codecvt/max_length/wchar_t/1.cc:  Cleanup.
	* testsuite/22_locale/codecvt/max_length/wchar_t/2.cc:  New test.
	* testsuite/22_locale/codecvt/max_length/wchar_t/3.cc:  New test.
	* testsuite/22_locale/codecvt/max_length/wchar_t/4.cc:  New test.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: codecvt2.diff.gz
Type: application/x-gzip
Size: 6851 bytes
Desc: codecvt2.diff.gz
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20030128/9db60cf2/attachment.bin>


More information about the Libstdc++ mailing list