How To Convert Ansi To Unicode

0 views
Skip to first unread message

Telly Piatt

unread,
Aug 3, 2024, 5:30:16 PM8/3/24
to mastvithevest

I'm converting a D2006 program to D2010. I have a value stored in a single byte per character string in my database and I need to load it into a control that has a LoadFromStream, so my plan was to write the string to a stream and use that with LoadFromStream. But it did not work. In studying the problem, I see an issue that tells me that I don't really understand how conversion from AnsiString to Unicode string works. Here is a piece of standalone code that illustrates the issue I am confused by:;

I'm not getting the right results out of the LoadFromStream because it is reading from the stream two bytes at a time, but the data it is receiving is not arranged that way. What is it that I should do to give the LoadFromStream a well formed stream of data based on a unicode string?

Please sum up first some infos out of your preliminary researches that make clear that Dynamo is the best tool for this task:
Tech Support Guy Solved: Does anyone know how to convert unicode files to ANSI?I am looking for a way to convert about 100 unicode text files from unicode to ANSI. I realise that notepad can do this by selecting Save As > ANSI,...

Please send also related researches links, you will easily find online resources and will need to make a first proposal:
stackoverflow.com Convert encoding of a text file from utf-8 to ansi or unicode in python python, text, encoding, utf-8 asked by narges on 09:50AM - 25 Dec 16

Unfortunately i am still looking for solution to this problem until today. However, i have just requested for help from Autodesk technical support team. Hopefully they will get back to me with a solution soon. If they do, i will update here.

I am waiting for reply with you. But how did you send the question to them? Existy some email or anything like this? Because I can send to them the same question, some times we can get the answer fastest

Your tips worked to my documents, but one document for time. However, I have diferents documents and I would like change enconding in the same time of every documents and I tried to do like this:
Capturar.JPG1500860 156 KB

3- I want to automate the process so that i won't lose formatting while at the same time the text in my document get replaced with unicode (i cant do it through - copy -convert-find and replace as it will take much time.)

Thank you for responding, educational project doesnt necessarily mean we are looking for pro bono support, we can pay but since its a its an educational project it wont match the industry standared rather it will be paid (some amount) as token of gratitude. I would be greatful if someone can support.

Thus, that would certainly be a interesting script to implement, subject that expertise and working time be fairly remunerated. As I wrote above, that's all the issue. But maybe @Robert at ID-Tasker is your solution, so get in touch with him.

I have gotten lost in these weeds myself, repeatedly trying to write a Limon -> Unicode converter for Khmer. Every few years, I say to myself "Okay, I'm lots better at JS now, I should take another stab at the Limon converter" and walk away converterless and totally humbled, every time.

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)

You'll find that the code below does what you're after. Instead of relying on the fact that your machine/user probably has the expected locale setting (which determines which ANSI codepage to use by default), I forced ANSI 1251 as you can see. Change that according to your needs.

Thanks for the response jchd. I can't really see through why your solution works (the DLL calls are quite complex), but since I need to convert between unicode and different codepages, I chose a different approach..

There is no magic in this function: this is what Windows uses to convert to/from any string representation. The first call is needed to get the output length, the second call perform the actual conversion. You can use all the codepages listed here.

I have myself a (large) number of files all tagged with who knows what character sets... some work in windows when not in the locale of origin, some don't. Is there a way to batch convert all the contents of the id3 tags to the unicode character set?

seems that just resaving the existing tags (while in the default locale of the origin language) with the unicode options set properly will fix the non unicode tag entries (so far it's been working) I tested this by copying the files to another computer not set in the same system locale and they displayed fine.

I have lots of id3v2.3 tags and I want them all to be UTF-16. I have the column in place showing me what isn't UTF-16; and so I can sort that column, select all the problem children, and then 'make the fix' but I just want to be sure I am making the optimal fix, and doing it properly.

If you have set File>Options>Mpeg to V2.3 UTF-16 then the pasting will insert the correct character codes.
And the copying, obviously, means additional data security if something should go wrong: you do not cut the tags and leave bare files but you paste the new information.

Reference Designs are software libraries, design patterns, and application architectures that provide recommendations and best practices for code design, as well as reusable code components. more\r\n\r\n\r\n\r\n\r\nREFERENCE DESIGN TYPE\r\n\r\nApplication Architectures and Frameworks
\r\nDesign Patterns and Templates
\r\nLibraries and Components
\r\nTools and Utilities
\r\nCommunity-provided Reference Designs\r\n\r\n\r\n

Following are my observations and findings while using Unicode in a LabVIEW UI application. The purpose of using Unicode in this application is to localize the UI on the fly in any language without having to change the Computer locale. The application provides a settings page which allows the user to select the language of the UI. Based on this setting all UI components (controls and indicators) are localized into the selected language. The resource strings for all controls/indicators and languages are read from a text file containing Unicode strings.

Disclaimer:

LabVIEW for Windows has limited support for Unicode strings in the front panel controls and indicators. This is not an offically supported feature, meaning that it is not as fully tested as other released parts of the development and run-time environment. In addition this feature is not covered under standard product support and parts of this feature may change in future releases of LabVIEW, i.e. any code developed on this feature may require changes when upgrading to a newer version of LabVIEW. If you have any feedback or questions about using Unicode in LabVIEW post them as comments on this document or in the Developer Zone discussion forums.

The code posted as part of this document has been developed and tested in LabVIEW 2009 running on Windows XP SP3 (English). The VIs are saved back to LabVIEW 8.6. Earlier versions of LabVIEW did not include all of this Unicode support and it is suggested that you upgrade to LabVIEW 8.6 or later if you want to use Unicode in your application development.

c80f0f1006
Reply all
Reply to author
Forward
0 new messages