How to transform like "€ " this code into character?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
pubuntu
Posts: 9
Joined: 22 May 2014, 00:05

How to transform like "€ " this code into character?

28 May 2014, 19:23

AHK provides the function :
Transform, HTML, String [, Flags]
can transform "€" this code into " €"
But I want to reverse back, and I not find the corresponding help.

I make a function to transform it,but it work Poor efficiency。Excuse me what method to solve it?

Code: Select all

unicode2ascii(str) {
    Loop {
        pos:=RegExMatch(str, "Om)&#(\d+);", findit)
        a:=findit.Pos()
        b:=Chr(findit.Value(1))
        str:=RegExReplace(str, "&#\d+;", b, , 1)
        if pos=0
            break
    }
    return str
}
How to transform like "€ " this code into character?
Ronins
Posts: 85
Joined: 02 Oct 2013, 11:38

Re: How to transform like "€ " this code into characte

29 May 2014, 00:26

Code: Select all

Chr(8364)
would get the job done.. It would work only on unicode version though..

Code: Select all

Transform, OutVar, HTML, £, 2
MsgBox, % OutVar

MsgBox, % Chr(SubStr(OutVar, 3, StrLen(OutVar)-3))
Try out CMD class
pubuntu
Posts: 9
Joined: 22 May 2014, 00:05

Re: How to transform like "€ " this code into characte

29 May 2014, 05:48

Ronins wrote:

Code: Select all

Chr(8364)
would get the job done.. It would work only on unicode version though..

Code: Select all

Transform, OutVar, HTML, £, 2
MsgBox, % OutVar

MsgBox, % Chr(SubStr(OutVar, 3, StrLen(OutVar)-3))
You code can word ,But it can translate only a charcte.I have a file mixed English letters and Chinese 。How to do .
Ronins
Posts: 85
Joined: 02 Oct 2013, 11:38

Re: How to transform like "€ " this code into characte

29 May 2014, 10:15

well, there are many ways to take care of that.. One can be to check out for Asc range
Other can be to check strLen() as regular english characters will have 1 length as they wont be transformed

Code: Select all

Char:= "ي"
;~ Char := "z"
Transform, Outvar, HTML, %Char%, 2
MsgBox, % OutVar
;~ if OutVar is not alpha
if(StrLen(OutVar)>1)
	BackChar := Chr((SubStr(OutVar, 3, StrLen(OutVar)-3)))
else
	BackChar := OutVar
MsgBox, % BackChar
Try out CMD class
pubuntu
Posts: 9
Joined: 22 May 2014, 00:05

Re: How to transform like "€ " this code into characte

29 May 2014, 19:34

Ronins wrote:well, there are many ways to take care of that.. One can be to check out for Asc range
Other can be to check strLen() as regular english characters will have 1 length as they wont be transformed

Code: Select all

Char:= "ي"
;~ Char := "z"
Transform, Outvar, HTML, %Char%, 2
MsgBox, % OutVar
;~ if OutVar is not alpha
if(StrLen(OutVar)>1)
	BackChar := Chr((SubStr(OutVar, 3, StrLen(OutVar)-3)))
else
	BackChar := OutVar
MsgBox, % BackChar
I have thousands of files , the content is like "ch 化粧品ch ch ch ch 通販"
How to construct a function to convert a string?
User avatar
LinearSpoon
Posts: 156
Joined: 29 Sep 2013, 22:55

Re: How to transform like "€ " this code into characte

29 May 2014, 21:39

I don't know if this is the most efficient way, but it's simple enough...

Code: Select all

test =
(Join<br>
ch &#21270;&#31911;&#21697;ch ch ch ch &#36890;&#36009;
&#8364;
)

Msgbox % Convert(test)

Convert(strHTML)
{
  doc := ComObjCreate("HTMLfile")
  doc.write(strHTML)
  return doc.body.innerText
}
pubuntu
Posts: 9
Joined: 22 May 2014, 00:05

Re: How to transform like "&#8364; " this code into characte

30 May 2014, 03:29

LinearSpoon wrote:I don't know if this is the most efficient way, but it's simple enough...

Code: Select all

test =
(Join<br>
ch &#21270;&#31911;&#21697;ch ch ch ch &#36890;&#36009;
&#8364;
)

Msgbox % Convert(test)

Convert(strHTML)
{
  doc := ComObjCreate("HTMLfile")
  doc.write(strHTML)
  return doc.body.innerText
}
thank you ! It runs faster than brfore.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Theda and 279 guests