|
[
Permlink
| « Hide
]
Martin Sebor added a comment - 22/Aug/07 02:34 PM
Assigned to Farid.
Changed from Improvement to a Bug – examples should never fail.
The example doesn't fail (crash or something). It's just return 1 to indicate that used locales not available.
Added output of the error message thus: http://svn.apache.org/viewvc?rev=574560&view=rev Changed type back to improvement and scheduled for 4.2.1. We cannot split this example into 3 examples, because there also present conversion test between EUC-JP and UTF-8 encodings through the internal representation.
Guesstimating the amount of work.
The example shows how to convert character strings representing Japanese (i.e., ja_JP) weekday names between the UTF-8, Shift_JIS, and EUC-JP encodings.
When invoked with no arguments or special variables in the environment it abends like so: $ ./codecvt1 ja_JP.UTF-8 -> INT -> ja_JP.UTF-8 Size comparison of buffers yields equal Content comparison of buffers yields equal Caught an exception: /home/sebor/stdcxx/src/locale_combine.cpp:644: std::locale::locale(const char*): bad locale name: "ja_JP.Shift_JIS" But when invoked with the RWSTD_LOCALE_ROOT environment variable set to point to the root of a directory tree containing the three locales above, i.e., ja_JP.UTF-8, ja_JP.Shift_JIS, and ja_JP.EUC-JP, it produces the expected output: $ make -C../bin ja_JP.UTF-8 ja_JP.Shift_JIS ja_JP.EUC-JP && RWSTD_LOCALE_ROOT=../nls ./codecvt1 make: Entering directory `/build/sebor/stdcxx-gcc-4.1.2-15D/bin' ./localedef -w -c -f /home/sebor/stdcxx/etc/nls/charmaps/UTF-8 -i /home/sebor/stdcxx/etc/nls/src/ja_JP /build/sebor/stdcxx-gcc-4.1.2-15D/nls/ja_JP.UTF-8 ./localedef -w -c -f /home/sebor/stdcxx/etc/nls/charmaps/Shift_JIS -i /home/sebor/stdcxx/etc/nls/src/ja_JP /build/sebor/stdcxx-gcc-4.1.2-15D/nls/ja_JP.Shift_JIS ./localedef -w -c -f /home/sebor/stdcxx/etc/nls/charmaps/EUC-JP -i /home/sebor/stdcxx/etc/nls/src/ja_JP /build/sebor/stdcxx-gcc-4.1.2-15D/nls/ja_JP.EUC-JP make: Leaving directory `/build/sebor/stdcxx-gcc-4.1.2-15D/bin' ja_JP.UTF-8 -> INT -> ja_JP.UTF-8 Size comparison of buffers yields equal Content comparison of buffers yields equal ja_JP.Shift_JIS -> INT -> ja_JP.Shift_JIS Size comparison of buffers yields equal Content comparison of buffers yields equal ja_JP.EUC-JP -> INT -> ja_JP.EUC-JP Size comparison of buffers yields equal Content comparison of buffers yields equal EUC-JP -> INT -> UTF-8 conversion Size comparison of buffers yields equal Content comparison of buffers yields equal So it looks to me like all we need to do to make the example behave in a useful way is to make sure the three locales exist (and that they are our own locales, not just the system ones) before invoking the program, and that the RWSTD_LOCALE_ROOT environment variable is set appropriately.
We can also rename the example to something more descriptive, like jpcvt.cpp. Added 4.2.0 to Affects Version/s.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||