Sign in to follow this  
Followers 0
mLipok

[SOLVED] Replacing national characters in a string

7 posts in this topic

#1 ·  Posted (edited)

How to replace national character in a string

Ö with O

Ä with A

Å with A

Ö >> o

Å >> a

and another similar characters

ę >> e

ą >> a

ś >> s

Edited by mlipok

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites



here are some docs

http://www.utf8-chartable.de/

for example

U+00EE î c3 ae LATIN SMALL LETTER I WITH CIRCUMFLEX

I want to convert î to i


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

yes

JohnOne

I know

this is the simplest way

but I try to find another method

My question is a question for these who very well know UNICODE standards

I think "maybe there is a trick to do that"

Edited by mlipok

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

long work and success

Func _Latin_char_Remover($string_to_change)

    $string_to_change = StringReplace($string_to_change, 'Á', 'A')
    $string_to_change = StringReplace($string_to_change, 'Â', 'A')
    $string_to_change = StringReplace($string_to_change, 'Ä', 'A')
    $string_to_change = StringReplace($string_to_change, 'Ç', 'C')
    $string_to_change = StringReplace($string_to_change, 'É', 'E')
    $string_to_change = StringReplace($string_to_change, 'Ë', 'E')
    $string_to_change = StringReplace($string_to_change, 'Í', 'I')
    $string_to_change = StringReplace($string_to_change, 'Î', 'I')
    $string_to_change = StringReplace($string_to_change, 'Ó', 'O')
    $string_to_change = StringReplace($string_to_change, 'Ô', 'O')
    $string_to_change = StringReplace($string_to_change, 'Ö', 'O')
    $string_to_change = StringReplace($string_to_change, 'Ú', 'U')
    $string_to_change = StringReplace($string_to_change, 'Ü', 'U')
    $string_to_change = StringReplace($string_to_change, 'Ý', 'Y')
    $string_to_change = StringReplace($string_to_change, 'Á', 'A')
    $string_to_change = StringReplace($string_to_change, 'Â', 'A')
    $string_to_change = StringReplace($string_to_change, 'Ä', 'A')
    $string_to_change = StringReplace($string_to_change, 'Ç', 'C')
    $string_to_change = StringReplace($string_to_change, 'É', 'E')
    $string_to_change = StringReplace($string_to_change, 'Ë', 'E')
    $string_to_change = StringReplace($string_to_change, 'Í', 'I')
    $string_to_change = StringReplace($string_to_change, 'Î', 'I')
    $string_to_change = StringReplace($string_to_change, 'Ó', 'O')
    $string_to_change = StringReplace($string_to_change, 'Ô', 'O')
    $string_to_change = StringReplace($string_to_change, 'Ö', 'O')
    $string_to_change = StringReplace($string_to_change, 'Ú', 'U')
    $string_to_change = StringReplace($string_to_change, 'Ü', 'U')
    $string_to_change = StringReplace($string_to_change, 'Ý', 'Y')
    $string_to_change = StringReplace($string_to_change, 'Ă', 'A')
    $string_to_change = StringReplace($string_to_change, 'ă', 'A')
    $string_to_change = StringReplace($string_to_change, 'Ą', 'A')
    $string_to_change = StringReplace($string_to_change, 'ą', 'A')
    $string_to_change = StringReplace($string_to_change, 'Ć', 'C')
    $string_to_change = StringReplace($string_to_change, 'ć', 'C')
    $string_to_change = StringReplace($string_to_change, 'Č', 'C')
    $string_to_change = StringReplace($string_to_change, 'č', 'C')
    $string_to_change = StringReplace($string_to_change, 'Ď', 'D')
    $string_to_change = StringReplace($string_to_change, 'ď', 'D')
    $string_to_change = StringReplace($string_to_change, 'Đ', 'D')
    $string_to_change = StringReplace($string_to_change, 'đ', 'D')
    $string_to_change = StringReplace($string_to_change, 'Ę', 'E')
    $string_to_change = StringReplace($string_to_change, 'ę', 'E')
    $string_to_change = StringReplace($string_to_change, 'Ě', 'E')
    $string_to_change = StringReplace($string_to_change, 'ě', 'E')
    $string_to_change = StringReplace($string_to_change, 'Ĺ', 'L')
    $string_to_change = StringReplace($string_to_change, 'ĺ', 'L')
    $string_to_change = StringReplace($string_to_change, 'Ľ', 'L')
    $string_to_change = StringReplace($string_to_change, 'ľ', 'L')
    $string_to_change = StringReplace($string_to_change, 'Ł', 'L')
    $string_to_change = StringReplace($string_to_change, 'ł', 'L')
    $string_to_change = StringReplace($string_to_change, 'Ń', 'N')
    $string_to_change = StringReplace($string_to_change, 'ń', 'N')
    $string_to_change = StringReplace($string_to_change, 'Ň', 'N')
    $string_to_change = StringReplace($string_to_change, 'ň', 'N')
    $string_to_change = StringReplace($string_to_change, 'Ő', 'O')
    $string_to_change = StringReplace($string_to_change, 'ő', 'O')
    $string_to_change = StringReplace($string_to_change, 'Ŕ', 'R')
    $string_to_change = StringReplace($string_to_change, 'ŕ', 'R')
    $string_to_change = StringReplace($string_to_change, 'Ř', 'R')
    $string_to_change = StringReplace($string_to_change, 'ř', 'R')
    $string_to_change = StringReplace($string_to_change, 'Ś', 'S')
    $string_to_change = StringReplace($string_to_change, 'ś', 'S')
    $string_to_change = StringReplace($string_to_change, 'Ş', 'S')
    $string_to_change = StringReplace($string_to_change, 'ş', 'S')
    $string_to_change = StringReplace($string_to_change, 'Š', 'S')
    $string_to_change = StringReplace($string_to_change, 'Š', 'S')
    $string_to_change = StringReplace($string_to_change, 'Ţ', 'T')
    $string_to_change = StringReplace($string_to_change, 'ţ', 'T')
    $string_to_change = StringReplace($string_to_change, 'Ť', 'T')
    $string_to_change = StringReplace($string_to_change, 'ť', 'T')
    $string_to_change = StringReplace($string_to_change, 'Ů', 'U')
    $string_to_change = StringReplace($string_to_change, 'ů', 'U')
    $string_to_change = StringReplace($string_to_change, 'Ű', 'U')
    $string_to_change = StringReplace($string_to_change, 'ű', 'U')
    $string_to_change = StringReplace($string_to_change, 'Ź', 'Z')
    $string_to_change = StringReplace($string_to_change, 'ź', 'Z')
    $string_to_change = StringReplace($string_to_change, 'Ż', 'Z')
    $string_to_change = StringReplace($string_to_change, 'ż', 'Z')
    $string_to_change = StringReplace($string_to_change, 'Ž', 'Z')
    $string_to_change = StringReplace($string_to_change, 'ž', 'Z')
    Return $string_to_change
EndFunc   ;==>_Latin_char_Remover
Edited by mlipok

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

Here's an example of how I might have gone about it.

Local $array[6] = ["À","Á","Â","Ã","Ä","Å"]

For $i = 0 To 5
  ConsoleWrite(_Replace($array[$i]) & @LF)
Next

Func _Replace($Char)
  Switch AscW($Char)
    Case 192 To 197
      ConsoleWrite("character " & AscW($Char) & " becomes ") ; just for demo
      Return "A"
    Case Else
      Return SetError(1,0,"")
  EndSwitch
EndFunc

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

The posted replacement list is very incomplete and doesn't handle complex things it needs to for covering what's called Latin letters.

I've had the need to build/handle a DB having columns in many scripts (i.e. languages using different alphabets). I ended up writing an SQLite extension writen in C doing that (folding, unaccenting) and much much more. When I need it, I invoke simply SQLite to do the work for me, by means of this extension. Something like those functions:

Func _Unaccent($str)
Return (_Sl3Answer($hMemDb, "select unaccent(" & X($str) & ");"))
EndFunc   ;==>_Unaccent
Func _Lower($str)
Return (_Sl3Answer($hMemDb, "select lower(" & X($str) & ");"))
EndFunc   ;==>_Lower
Func _LowerUnaccent($str)
Return (_Sl3Answer($hMemDb, "select lower(unaccent(" & X($str) & "));"))
EndFunc   ;==>_LowerUnaccent
Func _Upper($str)
Return (_Sl3Answer($hMemDb, "select upper(" & X($str) & ");"))
EndFunc   ;==>_Upper
Func _UpperUnaccent($str)
Return (_Sl3Answer($hMemDb, "select upper(unaccent(" & X($str) & "));"))
EndFunc   ;==>_UpperUnaccent
Func _Proper($str)
Return (_Sl3Answer($hMemDb, "select proper(" & X($str) & ");"))
EndFunc   ;==>_Proper
Func _ProperUnaccent($str)
Return (_Sl3Answer($hMemDb, "select proper(unaccent(" & X($str) & "));"))
EndFunc   ;==>_ProperUnaccent

This works well for me since I'm a heavy user of SQLite, so I always have at least a memory DB open and ready to tweak data in complex ways that SQL does in a snap but AutoIt would take too long to do. In short, it's a kind of external UDF for me.

If you can bear with having to use the SQLite Dll along your app, you could use it in exactly the same way.

OTOH, you can as well download the extension from here (it comes in full source and x86 dll) and invoke the function with DllCall directly.

BTW, the extension relies on cut-down tries compatible with Unicode v5.1, which covers a huge part of writen languages.

It's language-agnostic, which means it doesn't follow any specific Unicode locale.

The extension is ~180Kb in x86, to be compared to the whooping 18+ Mb of the complete ICU library.

All I ask is that you don't release a modified version under a name which could confuse people, or claim it's all your own work, which is a kind of licence I find fairly liberal.

Edited by jchd

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)

Share this post


Link to post
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
Sign in to follow this  
Followers 0