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 ----- 中田 , ネットワーク , サーバー , CAR (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 'ネットワ%' " and which should result ネットワーク I tried like this and it was oK "SELECT * FROM table1 WHERE item_name LIKE 'ネ%' " 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

In reply to how to change unicode string to byte array ? by nythu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.