Jump to content
Timing

How to convert string to Unicode?

Recommended Posts

Timing

Hi

I want to know how to convert string(Character) to Unicode. 

When i find the forum, it only have Unicode to something.

And Somebody know how to use Unicode in controlsend.

I want to know how to controlsend other language.

Please help me..

Share this post


Link to post
Share on other sites
jchd

Your request is overly vague. AutoIt string are Unicode, encoded in UCS2-LE (a subset of UTF16-LE for most humans).

What have you tried which didn't work?


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
Timing

In the controlsend()

when i use other language, then it doesn't send.

like Korean

When i use korean in controlsend, then it doesn't work

so i use string to Unicode and controlsend unicode, then i think it was work.

Example of korean: 한글

 

Share this post


Link to post
Share on other sites
Timing

Your request is overly vague. AutoIt string are Unicode, encoded in UCS2-LE (a subset of UTF16-LE for most humans).

What have you tried which didn't work?

In the controlsend()

when i use other language, then it doesn't send.

like Korean

When i use korean in controlsend, then it doesn't work

so i use string to Unicode and controlsend unicode, then i think it was work.

Example of korean: 한글

Share this post


Link to post
Share on other sites
jvds

get your char in Korean then try send CHRW(NUMBER) not sure it will work this way but it is the way i'll do it, here is a script i use to work with unicode
chrw(54620) will create 한, chrw(44544) will create 글, , the gui is not very spesific but names are for reference to the functions ASC() and CHRW() which is what you need to work with I believe

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Form2", 189, 78, 452, 327)
$Inputasc= GUICtrlCreateInput("", 40, 12, 33, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
$Inputchrw = GUICtrlCreateInput("", 120, 36, 57, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))

$Outputasc = GUICtrlCreateInput("", 120, 12, 57, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER),0)
GUICtrlSetBkColor(-1, 0x808080)
$Outchrw = GUICtrlCreateInput("", 40, 36, 33, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER),0)
GUICtrlSetBkColor(-1, 0x808080)

$Label1 = GUICtrlCreateLabel("ASC", 8, 16, 25, 17)
$Label2 = GUICtrlCreateLabel("CHRW", 80, 16, 38, 17)
$Label3 = GUICtrlCreateLabel("ASC", 8, 40, 25, 17)
$Label4 = GUICtrlCreateLabel("CHRW", 80, 40, 38, 17)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$inasctmp=""
$inchrwtmp=""
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch

    $inasc=GUICtrlRead($Inputasc)
    $inchrw=GUICtrlRead($Inputchrw)

    if $inasctmp <> $inasc then
;~      $inasc=StringTrimLeft($inasc,1)
        GUICtrlSetData($Outputasc,Ascw($inasc))
        $inasctmp = $inasc
    EndIf
    if $inchrwtmp <> $inchrw then
;~      $inchrw= StringTrimLeft($inchrw,1)
        GUICtrlSetData($Outchrw,Chrw($inchrw))
        $inchrwtmp = $inchrw
    EndIf




    ConsoleWrite('$inasc='&$inasc&@lf)
    ConsoleWrite('$inchrw='&$inchrw&@lf)

    sleep(20)
WEnd

example script

if not ProcessExists ("notepad.exe") then Run("notepad.exe")
    $hWnd = WinWait("[CLASS:Notepad]", "", 10)
    ControlSend($hWnd, "", "Edit1", chrw(54620)&chrw(44544))

 

Edited by jvds
example script
  • Like 1

Share this post


Link to post
Share on other sites
jchd

There is no need to split the string in individual codepoints then concatenating it back. Just use the string:

Local $sHi = "한국 안녕하세요!", $sKorean = "나와 함께 작동 여기 증거입니다."
Run("Notepad.exe")
Local $hw = WinWaitActive("[CLASS:Notepad]")
ControlSetText($hw, "", "Edit1", $sHi & @CRLF)
ControlSend($hw, "", "Edit1", $sKorean & @CRLF)
MsgBox(0, $sHi, $sKorean, 3)
WinActivate($hw)
Send("!Fq")
Send("{RIGHT}{ENTER}")

 


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

×