rousni Posted May 20, 2007 Share Posted May 20, 2007 (edited) According to the Help fileBinaryToString converts a binary variant into its ANSI string representation.What about a binary cyrillic text? I can't manage to convert a unicode text (for example a text in Russian copied to the Clipboard) into its ANSI string representation.By the way, this is feasible using AutoHotkey which does not have Unicode support (Clipbord Contents --> UTF-8 ---> ANSI string) Edited May 20, 2007 by rousni Link to comment Share on other sites More sharing options...
Gif Posted May 20, 2007 Share Posted May 20, 2007 (edited) According to the Help fileWhat about a binary cyrillic text? I can't manage to convert a unicode text (for example a text in Russian copied to the Clipboard) into its ANSI string representation.By the way, this is feasible using AutoHotkey which does not support Unicode (Clipbord Contents --> UTF-8 ---> ANSI string)don't think there is a possible waylook here and at Au3Lib..you can convert binary - HEX and binary - string but not cyrillic i think Edited May 20, 2007 by c4nm7 Link to comment Share on other sites More sharing options...
Administrators Jon Posted May 20, 2007 Administrators Share Posted May 20, 2007 According to the Help fileWhat about a binary cyrillic text? I can't manage to convert a unicode text (for example a text in Russian copied to the Clipboard) into its ANSI string representation.By the way, this is feasible using AutoHotkey which does not support Unicode (Clipbord Contents --> UTF-8 ---> ANSI string)What exactly are you trying to do? The whole binary/string thing is only usually useful if you are doing tcp/file editing (i.e. not very). If you tell us what you are trying to do there is probably a way to do it. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
rousni Posted May 20, 2007 Author Share Posted May 20, 2007 (edited) I am developing a translation program susceptible to manage efficiently an enormous (distributed) database. ANSI being a more economic format than Unicode, I prefer to store records as ANSI string. So the input is in Unicode, the output is in Unicode too, but the data is stored in ANSI (we need of course information about the language, i.e. the page code). Currently, this is developed using AutoHotkey (http://web.uni-plovdiv.bg/rousni) Edited May 20, 2007 by rousni Link to comment Share on other sites More sharing options...
Administrators Jon Posted May 20, 2007 Administrators Share Posted May 20, 2007 If it's stored in ANSI what's the problem? Conversion will happen automatically between ANSI and unicode. You mention Cryrillic text, so I don't think that's what you actually mean. Maybe you mean that you are storing data as UTF8? A UDF for a BinaryToStringW is this (might need $a and $b swapping, not sure) $binary = Binary("0x0041004200430044") ; ABCD MsgBox(0, "BinaryToStringW", _BinaryToStringW($binary) ) Func _BinaryToStringW($binary) Local $bytes = BinaryLen($binary) Local $a, $b Local $string Local $pos = 1 While $pos <= $bytes $a = Int( BinaryMid($binary, $pos, 1) ) $b = Int( BinaryMid($binary, $pos+1, 1) ) $pos += 2 $a = BitShift($a, -8) $a += $b $string &= ChrW($a) WEnd return $string EndFunc If you are messing with UTF8 though I don't think that will help. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
rousni Posted May 20, 2007 Author Share Posted May 20, 2007 (edited) Conversion will happen automatically between ANSI and unicode.Conversion happens automatically between ANSI and unicode only for the active code page; well, i need french and cyrillic at the same time.Copy some text in cyrillic in Microsft Word and then try to paste it in some plain text editor (like WinVi, Crimson Editor...) You'll get ????????(From Windows 95 to Windows Vista)_BinaryToStringW() is not what I need and in any case this is slow. I am sorry to say that in a AutoIt forum but I think that AutoHotkey is better in this field with these internal functions:Transform, OutputVar, Unicode ; Retrieves the clipboard's Unicode text as a UTF-8 string.Transform, Clipboard, Unicode, %MyUTF_String% ; Places Unicode text onto the clipboard.Once you have the UTF-8 string, it is easy to convert to ANSI string ( and vice versa) Edited May 20, 2007 by rousni Link to comment Share on other sites More sharing options...
Administrators Jon Posted May 21, 2007 Administrators Share Posted May 21, 2007 Once you have the UTF-8 string, it is easy to convert to ANSI string ( and vice versa)Ok, but I still don't understand how or why you are using UTF8 or how you are getting it into AutoIt. And I still don't understand what you want me to do about it? Once I understand what you are trying to do I can probably add something to help. But "convert something from the clipboard into UTF8" doesn't sound of any use when all the internal functions don't need any utf8/ansi hacks so I think I'm missing what you are trying to do. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
Administrators Jon Posted May 21, 2007 Administrators Share Posted May 21, 2007 I could very easily add versions of BinaryToString that assume UTF16 or UTF8 but I'd want to be sure that this actually solves whatever it is you are trying to do first. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now