1

How can I convert a 4 digit unicode escape sequence to the actual symbol in AutoIt e.g "\u00a5" to "¥"

rdp
  • 2,072
  • 4
  • 31
  • 55

1 Answers1

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