in reply to Re^2: how to change unicode string to byte array ?
in thread how to change unicode string to byte array ?

i have some other related problem. this is to convert ascii character 'A' to sjis (japanese full-width alphanumeric character) 'A' .

The easiest way might be to convert "plain ascii" characters into the unicode "fullwidth" characters first, then "Encode::encode()" the unicode string into shiftjis for output.

The unicode range for the "fullwidth" ASCII characters begins at \x{FF01} for "!" (exclamation mark), and then proceeds through the normal ASCII character sequence up through \x{FF5E}. So one way to convert "plain ASCII" to "fullwidth ASCII" would be like this:

use Encode; # pick one of the following lines to uncomment # (depends on what sort of display terminal you use): #binmode STDOUT, ":utf8"; #binmode STDOUT, ":encoding(shiftjis)"; $_ = join( '', map { chr() } 0x21 .. 0x7e ) . "\n"; # this is a test +string print; s/([!-~])/chr(ord($1)+0xFEE0)/eg; # convert plain ASCII to CJK fullwi +dth ASCII # print; # uncomment this when you have chosen which binmode line to +use
(update: adding missing colon in 2nd binmode line)