unicode string to code byte array ?

[email protected] Sun, 28 Sep 2008 10:22:19 -0700 (PDT)
Newsgroups perl.beginners.cgi
Organization http://groups.google.com
Message-ID <16eb41f2-e9da-413c-8a79-c161ead26b7a@r15g2000prh.googlegroups.com>
hello..
i am new to cgi perl and now i am writing web site that use mysql
database on japanese font.
I store the data in utf8 and the data in the mysql database table are
as the following form. (this is just example)

---------------
item_name
---------------
&'#20013;&'#30000;  ,
&'#12493;&'#12483;&'#12488:&'#12527:&'#12540:&'#12463:  ,
&'#12469;&'#12540:&'#12496:&'#12540:  ,
&'#65315;&'#65313:&'#65330;  ,

( i added apostrophe(') codes here for appearing codes here, real data
does not include ('))
and real readable data format is ..
-----
item_name
-----
&#20013;&#30000; ,
&#12493;&#12483;&#12488;&#12527;&#12540;&#12463;  ,
&#12469;&#12540;&#12496;&#12540;  ,
&#65315;&#65313;&#65330;   (this is japanese full width alphanumeric
character, not normal Ascii character)

.............
My problem is that when i try to search this name by SQL statement ,
how can i change the user input data to this code array format(like
"&'#20013;&'#30000;" ).(here also added apostrophe(') codes for
appearing codes )  I have tried with some code. It was OK to convert
one character.
I tried like that.

my $code = sprintf "%s", ord Encode::decode("sjis", $char);

this works for single character. So I tried for split string into
character array and to convert each character. But it was not ok.I
tried for splitting unicode string into character array using
"split()" like that.
my @StrAry = split(//,$srcStr);

But it was only ok for normal string and cannot divide unicode string.

So, please let me know if there any good solution for that.

I want to write for the sql statement like "SELECT * FROM table1 WHERE
item_name LIKE '&#12493;&#12483;&#12488;&#12527;%' " and which should
result &#12493;&#12483;&#12488;&#12527;&#12540;&#12463;
I tried like this and it was oK  "SELECT * FROM table1 WHERE item_name
LIKE '&#12493;%' " and which reults well.
But i cannot change user input string to related code array.

So, please help me if anyone know about unicode and mysql ,cgi perl.

Thnaks in advance
thu