Guidance
指路人
g.yi.org
Upload / Forum Attachment / Reginald Rexx Programming Language Compiler User Forum Attachments and Pictures / 12375-character_conversion_tables.rex

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
/*
 Convert DB2 unicode data read via ODBC to ANSI code

 For each character that is not translated correctly, review its
 hex value AFTER reading it from the mainframe with ODBC, then 
 look for this character in the tables shown at
 http://www.simotime.com/asc2ebc1.htm#Tables

 This presupposes that you KNOW the "real" characters in the
 DB2 table. For example, assume you know you inserted the string
 (as unicode) SCENIC SOUNDS into DB2. When you then do a C2X on
 this AFTER reading it via ODBC, you see the following hex values

 EB7BE12BF17B1AEB21ED2BE0EB

 For this, you can see that EB corresponds to the character S. 
 Based on that and the URL above, you would tranclate EB to 
 ascii/ansi 53 (which is the hex representation for the ASCII
 chcracter S in the URL table). Do this for any characters
 that are missing in the following table, simlpy adding each 
 hex value as a new character at the end of each string

 Arguments are:-

 tables				2-characters string containing a combination of
 							EAD. For example, ED would mean the first string
 							returned is the EBCDIC hex string of characters
 							and the second string returned is the DB2-unicode
 							equivalent characters.
 string1			Sets the 1st variable in the calling script to the 
 							equivalent hex characters for the 1st element
 							in tables
 string2			Sets the 2nd variable in the calling script to the 
 							equivalent hex characters for the 2nd element
 							in tables

 Return code  0 = ok, 1 error of some sort

*/
USE ARG tables, string1, string2
rc = 0

SELECT SUBSTR(tables,1,1) 
	WHEN 'D' THEN
	  string1 = db2_unicode()
	WHEN 'A' THEN
	  string1 = ansi_code()	
	WHEN 'E' THEN
	  string1 = ebcdic_code()		    
	OTHERWISE
		rc = 1
END	
	  
SELECT SUBSTR(tables,2,1) 
	WHEN 'D' THEN
	  string2 = db2_unicode()
	WHEN 'A' THEN
	  string2 = ansi_code()
	WHEN 'E' THEN
	  string2 = ebcdic_code()	  	  
	OTHERWISE
		rc = 1
END	

IF LENGTH(string1) <> LENGTH(string2) THEN
	rc = 1

RETURN rc
/******************************************************************
 Define the DB2 Unicode hex code
******************************************************************/
db2_unicode:

y = ''
y = y || "2FC223C0C1C324C7D1F62C255F3E3FF85CCACBC8CDCECFCCE93A"x 
/*         a b c d e f g h i j k l m n o p q r s t u v w x y z  */
y = y || "A0E27BE0E1E37DE7F1A72E3C282B212660EAEBE8EDEEEFECDFA4"x 
/*         A B C D E F G H I J K L M N O P Q R S T U V W X Y Z  */
y = y || "91169394959604989990"x 
/*         1 2 3 4 5 6 7 8 9 0  */ 		
y = y || "31323334353680"x   /* 4376437543B643654364436F */
/*         å ä ö Å Ä Ösp   */ 	
y = y || "06888B81178A89050783848C0A1A2A9A"x
/*         . ( + ! & * ) - / # $ , % ? \ :   */     
y = y || '01'x      

RETURN y
/******************************************************************
 Define the ANSI hex code
******************************************************************/
ansi_code:

y = ''
y = y || "6162636465666768696A6B6C6D6E6F707172737475767778797A"x 
/*         a b c d e f g h i j k l m n o p q r s t u v w x y z  */
y = y || "4142434445464748494A4B4C4D4E4F505152535455565758595A"x 
/*         A B C D E F G H I J K L M N O P Q R S T U V W X Y Z  */
y = y || "31323334353637383930"x 
/*         1 2 3 4 5 6 7 8 9 0  */ 		
y = y || "E5E4F6C5C4D620"x 
/*         å ä ö Å Ä Ösp   */ 
y = y || "2E282B21262A292D2F23242C253F5C3A"x
/*         . ( + ! & * ) - / # $ , % ? \ :   */      
y = y || '01'x 
      
RETURN y
/******************************************************************
 Define the EBCDIC hex code
******************************************************************/ 
ebcdic_code:

y = ''
y = y || "818283848586878889919293949596979899A2A3A4A5A6A7A8A9"x 
/*         a b c d e f g h i j k l m n o p q r s t u v w x y z  */
y = y || "C1C2C3C4C5C6C7C8C9D1D2D3D4D5D6D7D8D9E2E3E4E5E6E7E8E9"x 
/*         A B C D E F G H I J K L M N O P Q R S T U V W X Y Z  */
y = y || "F1F2F3F4F5F6F7F8F9F0"x 
/*         1 2 3 4 5 6 7 8 9 0  */ 		
y = y || "4743CC6763EC40"x 
/*         å ä ö Å Ä Ösp   */ 
y = y || "4B4D4E5A505C5D60617B5B6B6C6FE07A"x
/*         . ( + ! & * ) - / # $ , % ? \ :   */      
y = y || '01'x 
      
RETURN y
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Sun 2024-2-25  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2008-09-22 14:09:08