-3

I need to make some ebcdic_1141/cp1252 convertions. Here are the tables I found :

http://publib.boulder.ibm.com/infocenter/pcomhelp/v5r9/index.jsp?topic=/com.ibm.pcomm.doc/reference/html/hcp_reference02.htm

How do you make convertions tables from that. What I specificaly do not understand is what of the hex values before 40? And how do I get the hex values of each characters (which i will put into an array)?

Thanks, jacob

Sir Rufo
  • 18,395
  • 2
  • 39
  • 73
Jacob Ilyane
  • 85
  • 1
  • 1
  • 6
  • 1
    In what language? Most languages already include functions for encoding conversions, check whether yours supports the tables you want. – deceze Jun 18 '13 at 15:17
  • The language I use is delphi. I did not find any ready to use tables. – Jacob Ilyane Jun 18 '13 at 16:06
  • there is no any warranty that ALL the characters would be possible to map, only some subset would be the same. So, "before 40" might be just unconvertible. – Arioch 'The Jun 18 '13 at 17:09
  • please, specify your delphi version in question TAGs - edit your q and add proper tag – Arioch 'The Jun 18 '13 at 17:13

1 Answers1

1

IBM 1141 seems to be already part of Windows NT starting with Windows 2000 at least. Just ask system administrator to install it via Control Panel / Windows Components.

http://msdn.microsoft.com/en-us/library/windows/desktop/dd317756.aspx

Then, depending on your Delphi version you can

  1. use TEncoding class
  2. use AnsiString wich specified codepage (assign UnicodeString aka string from it) and/or use SetCodePage procedure
  3. use Win32 API MultiByteToWideChar to convert PAnsiChar to UTF-16, then convert it back to 1252
  4. using libraries like Jedi CodeLib that have readymade wrapper, doing the #3 flip-flop in one call.

Notice, please, that you should not expect ALL the characters to be mapped between those charsets. Some rare characters like control codes and diacritics may be present only in one of the charsets, and be missed from its counterpart. WideCharToMultiByte function mentions this specifically.


Alternative approaches (not necessary successful) may include:

  1. Aforementioned JCL.sf.net has it's own JclUnicode unit, that may have it's own built-in map instead of relying on Windows-provided map. I don't remember if IBM1141 is included or not though.
  2. IBM Classes for Unicode may include those codepages as well (or may not, but probably they would). Has anyone used ICU with Delphi?
  3. iconv library started on UNIX systems, but with porting of IDEs like CodeTyphon/Lazarus back to Windows they should have libiconv ported to Windows (probably as part of MSYS project) and contain Pascal headers for it. Try installing downloading CodeTyphon and see if you can re-use its libiconv units in Delphi.
Community
  • 1
  • 1
Arioch 'The
  • 15,799
  • 35
  • 62