How can I convert a 4 digit unicode escape sequence to the actual symbol in AutoIt
e.g "\u00a5" to "¥"
Asked
Active
Viewed 586 times
1

rdp
- 2,072
- 4
- 31
- 55
-
How are you getting the escape sequence input? And where are you trying to output? – merlin2011 Jul 30 '14 at 03:05
-
My autoIt code is called from a Python code. The AutoIt code runs as a subprocess. – rdp Jul 30 '14 at 03:07
-
I would do the conversion in Python first, and/or just [use a Python package](https://pypi.python.org/pypi/autopy/0.51) for keyboard and mouse automation. – merlin2011 Jul 30 '14 at 03:11
-
How can you do the same conversion in python? – rdp Jul 30 '14 at 03:15
-
See [this answer](http://stackoverflow.com/a/992314/391161). – merlin2011 Jul 30 '14 at 03:16
-
1It works for latin characters, but not for this symbol – rdp Jul 30 '14 at 03:32
1 Answers
5
You mean this?
#include <MsgBoxConstants.au3>
Local $sText = ""
For $i = 256 To 2048
$sText = $sText & ChrW($i) ; Or $sText &= ChrW($i) can be used as well.
Next
MsgBox($MB_SYSTEMMODAL, "Unicode chars 256 to 2048", $sText) ; Display the unicode characters between 256 to 2048.
or this :Special chars in Autoit
or this:?
#include <WinAPI.au3>
Local $str = "My name is \u00a5"
Local $utfStr = Execute("'" & StringRegExpReplace($str, "(\\u([[:xdigit:]]{4}))", "' & ChrW(0x$2) & '") & "'")
Local $ansiStr = _WinAPI_WideCharToMultiByte($utfStr)
MsgBox(64, "Unicode2Ansi", $utfStr & @CRLF & $ansiStr)
Exit

Xenobiologist
- 2,091
- 1
- 12
- 16
-
I was looking for the third part that you have mentioned. It works. Thanks – rdp Jul 30 '14 at 14:22
-
The last solution does not work if there is a ' inside the string. You have to escape it before. – Kite Oct 03 '18 at 22:51
-
You can i.e. change the 3rd line to : Local $utfStr = Execute("'" & StringRegExpReplace(StringReplace($str,"'","''"), "(\\u([[:xdigit:]]{4}))", "' & ChrW(0x$2) & '") & "'") . – Kite Oct 03 '18 at 23:05