Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2005
    Posts
    18
    Rep Power
    0

    Post Encoding problem


    Hi all,

    I need to know how can we convert UTF8 encoded string to EUC-JP encoded string?

    I have tried mb_convert_encoding php function, but it didn't work.

    Any idea?

    Thanks

    --
    Riz ...

    Free HTML to PDF Conversion
    @ www.PDFonFly.com
  2. #2
  3. The Typo King
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2006
    Posts
    224
    Rep Power
    39
    Why would you want to use EUC-JP instead of UTF-8? UTF-8 supports Japanese characters.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2005
    Posts
    18
    Rep Power
    0

    Post


    Originally Posted by Chaos Rabbit
    Why would you want to use EUC-JP instead of UTF-8? UTF-8 supports Japanese characters.
    Thanks for your reply.
    Yes, UTF8 works great when we want to save something to db, and then re-use it.
    But here I have a situation, where I need to send japnese characters through query string to yahoo japan auction website.
    This website require queryString data to be encrypted in euc-jp encoding otherwise it doesn't recognize it.

    got my point?

    --
    Riz ...

    Free HTML to PDF Conversion
    @ www.PDFonFly.com
  6. #4
  7. I love your chinese eyes :*
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jan 2006
    Location
    Her heart... she claims!
    Posts
    1,668
    Rep Power
    1049
    hey nice to hear someone is writing something for YJA, i have written some modules for YJA too like real time bidding script that bid from your own site users on fly without going on YJA site...

    you can use nifty and google translation tools by the way to get the accurate string in JP from Eng.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2005
    Posts
    18
    Rep Power
    0

    Post


    Thanks for your reply jojoba.

    We have used google/nifty translation of the site but problem is little different at this time.
    Please see
    http://development2.japanauctioncenter.com/auctions/search.php?find=apple
    You will see Japanese translation of apple on the page. I need to send this translation to yahoo japan auction search page in querystring. And I am told it must be in EUC-JP encoding to work properly.
    Can you suggest any solution?

    Thanks

    --
    Riz ...

    Free HTML to PDF Conversion
    @ www.PDFonFly.com
  10. #6
  11. I love your chinese eyes :*
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jan 2006
    Location
    Her heart... she claims!
    Posts
    1,668
    Rep Power
    1049
    if you are using cURL with PHP then it's easy, just sent the string to the yahoo search page and I hope it will work you dont need to use any encoding type because you already translated it and you have the accurate string with you , you now just need to send it to the YJA site.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2005
    Posts
    18
    Rep Power
    0
    If you see the source of the url i sent u, ou will see following utf8 characters
    & #12426; & #12435; & #12372;

    Which are displayed as japanese characters by browser.
    Now at this time I only need to redirect this page to yahoo auction search page with these characters in querystring.
    But when I redirect the page, yahoo doesn't understand these characters.

    Bcz these are not in euc-jp format?

    --
    Riz ...

    Free HTML to PDF Conversion @ www.PDFonFly.com
    Free PDF Conversion @ www.HTM2PDF.com
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jan 2005
    Posts
    1,586
    Rep Power
    275
    Originally Posted by mriz81
    I have tried mb_convert_encoding php function, but it didn't work.
    Can I ask how you tried it? Also what system are you on. You can use mb_list_encodings (); to see what the exact name of the Japanese character set is on your system. Because sometimes it's not just euc-jp or the system may not support it. So you would need to supply the (iso-2022-jp-ext) version instead.


    PHP Code:
    // string to convert

    $old_string '';

    // old encoding

    $old_encoding 'utf-8';

    // new encoding

    $new_encoding 'euc-jp';

    // default_encoding

    $default_encoding 'iso-2022-jp-ext';

    // system supported encoding types

    $types array_map 'strtolower'mb_list_encodings () );


    $new_string mb_convert_encoding $old_string, ( in_array $new_encoding$types ) ? $new_encoding $default_encoding ), $old_encoding ); 
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2005
    Posts
    18
    Rep Power
    0
    Thanks for your reply "printf"

    Problem is this that
    mb_convert_encoding($JAPWordinutf8, "EUC-JP", "auto")
    does nothing.

    And final url become like this

    http://search.auctions.yahoo.co.jp/jp/search?p=(apple+& #12426;& #12435;& #12372; )&f=0x2&alocale=0jp&mode=1&auccat=0

    which is not understandable by yahoo.

    if you see
    http://development2.japanauctioncenter.com/auctions/search.php?find=apple

    I tried to show the encodings list, but it failed and gives error.

    --
    Riz ...

    Free HTML to PDF Conversion @ www.PDFonFly.com
    Free PDF Conversion @ www.HTM2PDF.com
  18. #10
  19. I love your chinese eyes :*
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jan 2006
    Location
    Her heart... she claims!
    Posts
    1,668
    Rep Power
    1049
    hmm, i got your point.... though of an idea and wanted to share with you.. as i saw on your site that you show all results / output from YJA in Eng. then why dont you fetch the JP string on fly and instead of displaying it in the browse send it to the YJA site ? by the way i think if your browser has support for JP characters then it must show you original characters in the source code instead of alphanumeric values... I remember when I was doing http sniffing of YJA to write the real time bidding script, i installed JP support in my browser and whenever I read the source it was in the actual JP format...
  20. #11
  21. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2005
    Posts
    18
    Rep Power
    0
    At this time, my client need only to open a new window having yahoo auction search results. ( its his requirement )

    In fact many popular english terms with their japanese equalant are already saved in database in utf-8 format. Which I am reading from database on this page and then redirecting to yahoo.
    But need to convert to proper encoding type first.

    --
    Riz ...

    Free HTML to PDF Conversion @ www.PDFonFly.com
    Free PDF Conversion @ www.HTM2PDF.com
  22. #12
  23. I love your chinese eyes :*
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jan 2006
    Location
    Her heart... she claims!
    Posts
    1,668
    Rep Power
    1049
    oh, that is very easy dude, first of all find the YJA page that display the search results. then when your site user submits query first go to nifty or google translation kinda site and from there send that query to nifty or google translation page with JP to Eng parameters,. they will display the results automatically in English, regex it from html and display in the pop up simple is that

    e.g

    Code:
    http://auctions.yahoo.co.jp?search.php?query=$yourForVariable
    send the above URL to Google translation or nifty kinda tool's that page which translate the JP to Eng....
  24. #13
  25. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2005
    Posts
    18
    Rep Power
    0
    Originally Posted by jojoba
    Code:
    http://auctions.yahoo.co.jp?search.php?query=$yourForVariable
    I am using same concept as u said. Only difference is this, that we have already maintained a dictionary for english to japanese conversion.
    So when user types something in english, its japanese translation is retrieved from database and concatenated with search url of japan auctions.
    So if user input is $Input, we get

    PHP Code:
    $JapaneseString GetJPTranslationFromDB($Input);
    $FinalUrl "http://search.auctions.yahoo.co.jp/search?query=$JapaneseString";
    header("Location: $FinalUrl"); 
    But, the japanese translation in database is stored in utf-8 format. Which does not work well in querystring. And must be changed before making the $FinalUrl.

    I hope this is clear now.

    --
    Riz ...

    Free HTML to PDF Conversion @ www.PDFonFly.com
    Free PDF Conversion @ www.HTM2PDF.com
  26. #14
  27. I love your chinese eyes :*
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jan 2006
    Location
    Her heart... she claims!
    Posts
    1,668
    Rep Power
    1049
    to store Eng to JP dictionary in db doesn't make any sense to me. If you are going to use nifty or google translation then why do take the hassle of first translating the string to jp and then send it to yahoo japan auctions site and then get output in jp and translate that into Eng and show on the page...

    say if auctions.yahoo.co.jp?searchresults.php?string=xxxxxxxxxxxxxxxx

    display the results then hardcode the URL and attach the string dynamically with it then send it to the Google or Nifty translation page it will automatically show you results in Eng and then regex to fetch the output...

    this is what i can think of..
  28. #15
  29. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2005
    Posts
    18
    Rep Power
    0
    Originally Posted by jojoba
    to store Eng to JP dictionary in db doesn't make any sense to me. If you are going to use nifty or google translation then why do take the hassle of first translating the string to jp and then send it to yahoo japan auctions site and then get output in jp and translate that into Eng and show on the page...

    say if auctions.yahoo.co.jp?searchresults.php?string=xxxxxxxxxxxxxxxx

    display the results then hardcode the URL and attach the string dynamically with it then send it to the Google or Nifty translation page it will automatically show you results in Eng and then regex to fetch the output...

    this is what i can think of..
    Dear jojoba, At this time we don't want to show english translated version. We only want to display a search page in japanese language.

    So if auctions.yahoo.co.jp?searchresults.php?string=xxxxxxxxxxxxxxxx is the search page, we only want xxxxxxxxxxxx to be the japanese equivalent of english term user typed.

    So if user typed xxxx we convert it to yyyy ( japanese equivalent ) then open
    auctions.yahoo.co.jp?searchresults.php?string=yyyy

    The problem is this , that yyyy is in utf8 and we want it in euc-jp

    --
    Riz ...

    Free HTML to PDF Conversion @ www.PDFonFly.com
    Free PDF Conversion @ www.HTM2PDF.com
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo