Sign in to follow this  
Followers 0
toyotabedzrock

ReplaceStringInFile and UCS2- Little Endian

2 posts in this topic

Hey all, heres the problem. I have an xml file with an xmlns attribute and it for some reason prevents the _XMLDomWrapper UDF from working properly. Anyway i need to replace the line containing the xmlns attribute, but when i do it converts the file to ANSI and i need it to be kept in UCS-2 Little Endian.

Share this post


Link to post
Share on other sites



Hey all, heres the problem. I have an xml file with an xmlns attribute and it for some reason prevents the _XMLDomWrapper UDF from working properly. Anyway i need to replace the line containing the xmlns attribute, but when i do it converts the file to ANSI and i need it to be kept in UCS-2 Little Endian.

Are you sure it isn't just UTF-16? From Wikipedia:

UCS-2 (2-byte Universal Character Set) is an obsolete character encoding which is a predecessor to UTF-16. The UCS-2 encoding form is nearly identical to that of UTF-16, except that it does not support surrogate pairs and therefore can only encode characters in the BMP range U+0000 through U+FFFF. As a consequence it is a fixed-length encoding that always encodes characters into a single 16-bit value. As with UTF-16, there are three related encoding schemes (UCS-2, UCS-2BE, UCS-2LE) that map characters to a specific byte sequence.

Because of the technical similarities and upwards compatibility from UCS-2 to UTF-16, the two encodings are often erroneously conflated and used as if interchangeable, so that strings encoded in UTF-16 are sometimes misidentified as being encoded in UCS-2.

The AutoIt FileRead() will automatically detect Unicode/ANSI encoding and shouldn't be an issue. If you always FileOpen() for write, then you can specify the Unicode format (see the help file under FileOpen() for the flags).

In the _XMLDomWrapper.au3 UDF your installed version of msxml.dll is used and presumably honors the encoding identified in the XML header. But that only helps if you save the DOM to a file using those calls, not FileWrite(), as in: $oXML.save($sPath)

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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