Author Topic: How to read Unicode  (Read 4337 times)

0 Members and 1 Guest are viewing this topic.

Jeremy

  • Guest
How to read Unicode
« on: January 19, 2012, 11:05:12 PM »
We have the ASCII and CHR functions to deal with ASCII codes. VL-STRING->LIST converts a string to a list of Ascii codes. Is there any way to extract Unicode character codes from a string in AutoLISP? I would like a routine that would act like VL-STRING->LIST only that would return Unicode codes.

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: How to read Unicode
« Reply #1 on: January 20, 2012, 02:26:33 AM »
Perhaps something like attached?

Though note it's loading the entire UniCode data list into RAM - uses just under 10MB for such. Though you'd then be able to convert to UniCode or UTF8 from there.

It's probably not the most efficient way of doing this, but it's a pure AutoLisp way. Thus it "should" work even on ACad for mac / BricsCAD on Linux.
« Last Edit: January 20, 2012, 02:32:26 AM by irneb »
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Lee Mac

  • Seagull
  • Posts: 12927
  • London, England
Re: How to read Unicode
« Reply #2 on: January 20, 2012, 07:10:07 AM »

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: How to read Unicode
« Reply #3 on: January 23, 2012, 02:50:39 AM »
I've been working on a DotNet implementation of this. The attached is the source in C# together with the Debug / Release DLL's - made in Visual Studio 2008. I've tested on ACad 2011/12 thus far. The file read/write routines still have an issue, but the attached converts properly between ASCII/UniCode/UTF7/UTF8/UTF32.

NetLoad one of the DLL's in the folder .\BinaryFiles\bin\Debug or .\BinaryFiles\bin\Release.

Then you should have several new lisp functions to call: string-to-unicode, string-to-ASCII, string-to-UTF7, string-to-UTF8, string-to-UTF32, unicode-to-string, ascii-to-string, UTF7-to-string, UTF8-to-string, UTF32-to-string.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.