Jump to content

Best way to decode multilanguage Character


rootx
 Share

Recommended Posts

On my script I work with a multiple languages, but I'm not sure why somethimes the result of binarytostring fail. My source is an XML file UTF-8

Ōgaki-shi = Ogaki ???

中央区 = Chūō  = Chuo ???

Zürich = Zurich --------> BinaryToString($dBinary,4) works

THX

 

Link to comment
Share on other sites

You post doesn't make much sense. Post code to reproduce a problem.

AutoIt uses Unicode, just like Windows and there is no such beast as "decoding multilanguage Character". If your input uses a different encoding, there are functions able to convert to/from anything you need.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

<?xml version="1.0" encoding="UTF-8"?>
<GeocodeResponse>
 <status>OK</status>
 <result>
  <type>political</type>
  <type>sublocality</type>
  <type>sublocality_level_4</type>
  <formatted_address>1 Chome-37-1 Asakusa, Taitō-ku, Tōkyō-to 111-0032, Giappone</formatted_address>
  <address_component>
   <long_name>1</long_name>
   <short_name>1</short_name>
   <type>political</type>
   <type>sublocality</type>
   <type>sublocality_level_4</type>
  </address_component>
  <address_component>
   <long_name>37</long_name>
   <short_name>37</short_name>
   <type>political</type>
   <type>sublocality</type>
   <type>sublocality_level_3</type>
  </address_component>
  <address_component>
   <long_name>1 Chome</long_name>
   <short_name>1 Chome</short_name>
   <type>political</type>
   <type>sublocality</type>
   <type>sublocality_level_2</type>
  </address_component>
  <address_component>
   <long_name>Asakusa</long_name>
   <short_name>Asakusa</short_name>
   <type>political</type>
   <type>sublocality</type>
   <type>sublocality_level_1</type>
  </address_component>
  <address_component>
   <long_name>Taitō-ku</long_name>
   <short_name>Taitō-ku</short_name>
   <type>locality</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>Tōkyō-to</long_name>
   <short_name>Tōkyō-to</short_name>
   <type>administrative_area_level_1</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>Giappone</long_name>
   <short_name>JP</short_name>
   <type>country</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>111-0032</long_name>
   <short_name>111-0032</short_name>
   <type>postal_code</type>
  </address_component>
  <geometry>
   <location>
    <lat>35.7127796</lat>
    <lng>139.7966054</lng>
   </location>
   <location_type>ROOFTOP</location_type>
   <viewport>
    <southwest>
     <lat>35.7114306</lat>
     <lng>139.7952564</lng>
    </southwest>
    <northeast>
     <lat>35.7141286</lat>
     <lng>139.7979544</lng>
    </northeast>
   </viewport>
  </geometry>
  <place_id>ChIJ46VqO8GOGGAR-UzmJAzGWN0</place_id>
 </result>
 <result>
  <type>political</type>
  <type>sublocality</type>
  <type>sublocality_level_3</type>
  <formatted_address>1 Chome-37 Asakusa, Taitō-ku, Tōkyō-to 111-0032, Giappone</formatted_address>
  <address_component>
   <long_name>37</long_name>
   <short_name>37</short_name>
   <type>political</type>
   <type>sublocality</type>
   <type>sublocality_level_3</type>
  </address_component>
  <address_component>
   <long_name>1 Chome</long_name>
   <short_name>1 Chome</short_name>
   <type>political</type>
   <type>sublocality</type>
   <type>sublocality_level_2</type>
  </address_component>
  <address_component>
   <long_name>Asakusa</long_name>
   <short_name>Asakusa</short_name>
   <type>political</type>
   <type>sublocality</type>
   <type>sublocality_level_1</type>
  </address_component>
  <address_component>
   <long_name>Taitō-ku</long_name>
   <short_name>Taitō-ku</short_name>
   <type>locality</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>Tōkyō-to</long_name>
   <short_name>Tōkyō-to</short_name>
   <type>administrative_area_level_1</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>Giappone</long_name>
   <short_name>JP</short_name>
   <type>country</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>111-0032</long_name>
   <short_name>111-0032</short_name>
   <type>postal_code</type>
  </address_component>
  <geometry>
   <location>
    <lat>35.7126408</lat>
    <lng>139.7960277</lng>
   </location>
   <location_type>GEOMETRIC_CENTER</location_type>
   <viewport>
    <southwest>
     <lat>35.7112751</lat>
     <lng>139.7948124</lng>
    </southwest>
    <northeast>
     <lat>35.7139731</lat>
     <lng>139.7975104</lng>
    </northeast>
   </viewport>
   <bounds>
    <southwest>
     <lat>35.7124158</lat>
     <lng>139.7956557</lng>
    </southwest>
    <northeast>
     <lat>35.7128324</lat>
     <lng>139.7966671</lng>
    </northeast>
   </bounds>
  </geometry>
  <place_id>ChIJ1yS7JsGOGGARSmB0sZggAXk</place_id>
 </result>
</GeocodeResponse>

Thx, I read this xml <formatted_address>1 Chome-37-1 Asakusa, Taitō-ku, Tōkyō-to 111-0032, Giappone</formatted_address>

Taito-ku and not Taitō-ku   <------------------- UTF-8 ō to ASCII o

Tokyo-to 111-0032 and not Tōkyō-to 111-0032

or in spanish Placa de la Sagrada Família and not Plaça de la Sagrada Família  <------------ UTF-8 ç to ASCII c    Etc...

and this for the other languages, my goal is write a legible words. thx

 

 

Edited by rootx
Link to comment
Share on other sites

Are you converting it to the symbol that most closely visually matches the shape of the character, or converting to the symbol that matches phonetically?

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

You mean you want to ignore diacritics in roman languages and convert accented and otherwise decorated characters to their "closest" unaccented base char?

If you want to perform this without embarquing the whole ICU library (a monster) yet obtain a relatively correct result you can do the following: use a Windows primitive to convert the UTF16 AutoIt string having normalization form C (NFC) into an UTF16 string having form D (NFD, or better form NFKD if this looks better for you). Then process this string to drop any codepoint > 0x127. This last step can be easily and elegantly done by a regexp.

Consult this primer: https://en.wikipedia.org/wiki/Unicode_equivalence

For how to persuade Windows to convert from one form into another, see: https://msdn.microsoft.com/en-us/library/windows/desktop/dd374126(v=vs.85).aspx

 

 

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Yes I was looking for this!!! THX. Why I ask this? because i created a script that uses exiftool to fetch exif and GPS data, the problem is that when Exiftool encounters folders with umlaut or other accented characters or in other languages it fails to read the directory. I follow the help but doesn't work. Now I evaluating a valid approach to solving the problem. https://sno.phy.queensu.ca/~phil/exiftool/faq.html#Q10

Edited by rootx
Link to comment
Share on other sites

You say this Windows program is incompatible with Windows? Gosh! Find anoher one.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Googling exif extract should answer the question

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...