perl-unicode

Re: Converting UTF-EBCDIC to UTF-8

2003-03-21 05:30:04
>### TESTS START
>$utf8_fe7f_upgraded = ord("A") != 0x41
>? pack('U*', 213, 190, 215)  # EBCDIC "\xef\xb9\xbf"
>: pack('U*', 239, 185, 191); # ASCII  "\xef\xb9\xbf"
>
>$utf8_fe7f_bytes = pack('C*', 239, 185, 191);
>
>print "\x{fe7f}" eq utf8_to_unicode($utf8_fe7f_upgraded)
>? "ok" : "not ok", " 25\n";
>
>print "\x{fe7f}" eq utf8_to_unicode($utf8_fe7f_bytes)
>? "ok" : "not ok", " 26\n";
>
>print  $utf8_fe7f_upgraded eq unicode_to_utf8("\x{fe7f}")
>? "ok" : "not ok", " 27\n";
>
>print  $utf8_fe7f_bytes    eq unicode_to_utf8("\x{fe7f}")
>? "ok" : "not ok", " 28\n";
>### TESTS END

I have replace test cases 25 - 28 with the ones listed above. And the results were as follows:

/defects/brian/unicode/Unicode-Transform-0.20:>make test
PERL_DL_NONLAZY=1 /defects/brian/nonthreaded/perl-5.8.0/perl "-I/defects/brian/n onthreaded/perl-5.8.0/lib" "-I/defects/brian/nonthreaded/perl-5.8.0/lib" "-MExtU
tils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/handler....ok
t/test.......ok
All tests successful.
Files=2, Tests=38,  3 wallclock secs ( 0.37 cusr +  0.12 csys =  0.49 CPU)

One more thing though. I am writing a XS module myself and I would like to convert C strings from UTF-EBCDIC to UTF-8 and back. Your module works well from Perl space, but do you have any ideas of how I can do this from C?

Thanks
Brian