Jump to content

String replace French characters !!


Recommended Posts

hi

i want to stringreplace the fresh characters with the utf code like the following 

$word = StringReplace($word,"â","%C3%A2")
$word = StringReplace($word,"é","%c3%a9")
$word = StringReplace($word,"è","%c3%a8")
$word = StringReplace($word,"ê","%c3%aa")
$word = StringReplace($word,"ë","%c3%ab")

for the upper code every thing is fine and good

when i try other characters like õ ô ó ò scite will show them as question marks like this

$word = StringReplace($word,"?","%c3%b3")

any fix for this or work around ? 

Edited by Alexxander

Link to comment
Share on other sites

You probably need to change the script encoding. Open it in SciTE and go to File > Encoding and click UTF-8. I think that is the one usually recommended. Then make any change to the file so you can save it, and now you should be able to copy your characters without them turning to "?".

Link to comment
Share on other sites

You can also work with StringRegExpReplace and the x option (followed by a unicode value).

This seems to work :

$sString = "Les accents vont être remplacés par leur caractère unicode. Par contre, il faut savoir que certains caractères comme ã, õ, ò ou ó ne sont pas utilisés dans la langue française."
$iIndex = 2

$sResult = $sString
For $i = 10 To 15
    If $i >= 13 Then $iIndex = 3
    For $j = 0 To 15
        $sCode = StringLower(Hex($i, 1) & Hex($j, 1))
        $sResult = StringRegExpReplace($sResult, "\x" & $sCode , "%c" & $iIndex & "%" & $scode)
    Next
Next

ConsoleWrite($sResult & @CRLF )
Edited by jguinch
Link to comment
Share on other sites

Alexxander,

If you actually need to convert an AutoIt string (which is already Unicode) into UTF8, then you should do that this way:

$s = BinaryToString(StringToBinary($s, 4), 1)

But it is unclear to me if you really want/need to do that. In all cases, switch to UTF8 source encoding as explained above.

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

You could also look at the functions ASC and CHR in the Help file, and the extended ASCII character set in the Appendix.

i.e. $word = StringReplace($word, Chr(245), "%c3%b3")

Edited by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

AscW, ChrW and using Unicode codepoint values would be much, much safer!  Extended ASCII is codepage-dependant.

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...