NVH’s Blog

January 8, 2007

Validate tieng Nhat voi encoding Shift-JIS

Filed under: hoc tap

Validate tieng Nhat voi encoding Shift-JIS
Sau đây là các regular expressions dùng để validate tiếng Nhật dùng encoding Shift-JIS (da test trên PHP):

1. Check các ký tự trong bảng mã Shift-JIS:
$pattern = ‘/^([\x00-\x7F\xA1-\xDF]|[\x81-\x9F\xE0-\xFC][\x40-\x7E\x80-\xFC])*$/’;

2. Check các ký tự haft size:
$pattern = ‘/^[\x00-\x7F\xA1-\xDF]* $/’;

3. Check Katakana Fullsize:
$pattern = ‘/^(([\x83][\x40-\x7e\x80-\x8f\x92\x93])|([\x81][\x45\x5b]))*$/’;

4. Check Hiragana:
$pattern = ‘/^([\x82][\x9f-\xed\xf0\xf1])*$/’;

5. Check Katakana haft size:
$pattern = ‘/^([\xa6-\xdf])*$/’;

7 Comments »

The URI to TrackBack this entry is: http://hungnv.blogsome.com/2007/01/08/validate-tieng-nhat-voi-encoding-shift-jis/trackback/

  1. Tieng Anh full size:
    $pattern = ‘/^([x82][x60-x79x81-x9a1])*$/’;

    Comment by hungnv — January 8, 2007 @ 4:26 am

  2. Mastering Regular Expressions at URL: http://www.mamiyami.com/document/regex/

    Comment by hungnv — January 8, 2007 @ 6:08 am

  3. hic ong viết khó hiểu quá. liệu có thể giải thích kỹ hơn được không? ví dụ tôi muốn chuyển fullsize thành halfsize tất cả các ký tự nhập vào = javascript thì hướng dẫn tôi được không?

    Comment by daicabuondoi — April 6, 2007 @ 10:22 am

  4. toi muom hoc tieng nhat .co ai huong dan cho tui ko vay ah/
    toi cam con nhe.

    Comment by quy — May 31, 2008 @ 5:37 am

  5. co ai la huong dan vien cho tui hoc tieng NHAT ko vay ah
    toi cam on truoc nhe

    Comment by quy — May 31, 2008 @ 5:39 am

  6. function isFull(value){
    for(i = 0; i 0xff00 && c 0xff00 && c 255) {
    if ((c >> 8) != 0xFF) {
    return false;
    }
    }
    }
    return true;
    }
    Note : Dựa vào 2 function này check sau đó thực hiện chuyển thì quá đơn giản rồi.

    Comment by Culeu — June 27, 2008 @ 7:41 am

  7. function isHalf(value){
    var total = 0;
    var n = value.length;
    var c;
    for (i = 0;i 0xff00 && c 255) {
    if ((c >> 8) != 0xFF) {
    return false;
    }
    }
    }
    return true;
    }

    Comment by Culeu — June 27, 2008 @ 7:42 am

RSS feed for comments on this post.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>























Get free blog up and running in minutes with Blogsome
Theme designed by Hadley Wickham