Sign in to follow this  
Followers 0
crystalburner

UniC

7 posts in this topic

i need to write a single string to a file as unicode text

anyone have any idea as autoit just seems to write ascii with the filewrite commands

C

Share this post


Link to post
Share on other sites



Raw write the values directly. Use FileOpen in RawMode and then write them as a binary string... If you need an example i can show you.

Share this post


Link to post
Share on other sites

Raw write the values directly. Use FileOpen in RawMode and then write them as a binary string... If you need an example i can show you.

Um i think i do!

www.ascii2binaryconverter.com?

Share this post


Link to post
Share on other sites

$Example=FileOpen(@ScriptDir&"\example.txt",2)
;Opens File
RawWrite($Example,"FFFE6100")
;Writes Hex to the file. FFFE6100 is the unicode code for the letter 'a'
FileClose($Example)

Func RawWrite($File,$Hex)
    If IsInt(StringLen($Hex)/2)=0 Then Return (-1)
    Local $a
    For $a=1 To StringLen($Hex) Step 2
        FileWrite($File,Chr(Dec(StringMid($Hex,$a,2))))
    Next
EndFunc

This will write the letter 'a' to example.txt in the run directory in unicode.

Share this post


Link to post
Share on other sites

$Example=FileOpen(@ScriptDir&"\example.txt",2)
;Opens File
RawWrite($Example,"FFFE6100")
;Writes Hex to the file. FFFE6100 is the unicode code for the letter 'a'
FileClose($Example)

Func RawWrite($File,$Hex)
    If IsInt(StringLen($Hex)/2)=0 Then Return (-1)
    Local $a
    For $a=1 To StringLen($Hex) Step 2
        FileWrite($File,Chr(Dec(StringMid($Hex,$a,2))))
    Next
EndFunc

This will write the letter 'a' to example.txt in the run directory in unicode.

fuck me

this is going to be tricky!

"JET " & @computername & "\Microsoft Information Store\First Storage Group\"

!!

Share this post


Link to post
Share on other sites

Made you a present. Look at http://www.autoitscript.com/forum/index.php?showtopic=30149

It's not to tricky :whistle: and you can modify it to suit your specific needs.

cool

#include <constants.au3>

#NOTRAYICON

#include <file.au3>

$raw="JET " & @computername & "\Microsoft Information Store\First Storage Group\"

$string=Asc2Unicode($raw)

$file=fileopen(@ScriptDir & "\exchange.bks",2)

FileWrite($file,$string)

fileclose($file)

exit

Func Asc2Unicode($AscString, $addBOM = false)

Local $BufferSize = StringLen($AscString) * 2

Local $FullUniStr = DllStructCreate("byte[" & $BufferSize + 2 & "]")

Local $Buffer = DllStructCreate("byte[" & $BufferSize & "]", DllStructGetPtr($FullUniStr) + 2)

Local $Return = DllCall("Kernel32.dll", "int", "MultiByteToWideChar", _

"int", 0, _

"int", 0, _

"str", $AscString, _

"int", StringLen($AscString), _

"ptr", DllStructGetPtr($Buffer, 1), _

"int", $BufferSize)

DllStructSetData($FullUniStr, 1, 0xFF, 1)

DllStructSetData($FullUniStr, 1, 0xFE, 2)

If $addBOM then

Return DllStructGetData($FullUniStr, 1)

Else

Return DllStructGetData($Buffer, 1)

Endif

EndFunc

Func __CharacterIsApha($s_Str); check string is alpha

Local $a_Alpha = "abcdefghijklmnopqrstuvwxyz"

Return (StringInStr($a_Alpha, $s_Str))

EndFunc ;==>__CharacterIsApha

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
Sign in to follow this  
Followers 0