IBM / JTOpen

IBM Toolbox for Java, an IBM i communications library
https://ibm.github.io/JTOpen/
Other
64 stars 28 forks source link

JTOpen #192

Closed mklassen60 closed 2 months ago

mklassen60 commented 4 months ago

We have a program that returns a string. This has worked with other programs but it seems that this case has some encoding that is not working with the output. The IBM programmers are not familiar with the encoding issue but see it is valid at the end of the program before it's returned to JTOpen.

In the non-JTOpen response the value: Delivered In the Node program running JTOpen: \u0004ᅤᅮ￉¥ᅤ￙ᅤᅣ When displaying the output in Postman: ᅤᅮ￉¥ᅤ￙ᅤᅣ€€€€€€€€€€€€€€€€

Is there some way to enforce or modify encoding after it comes from the JTOpen regarding strings? I did see this in code but may be incorrect:

jeber-ibm commented 2 months ago

You'll need to provide more details about what you are doing. A JTOpen trace would be helpful as well to see what the JTOpen code is doing.

mklassen60 commented 2 months ago

As an update, the issue was Ebcidic encoding. After we had the JTOpen response, we had to read the hex code and convert it to a non-IBM language for output based on if CCSID was 500 or 37 in our cases. This list could be useful for others who run into encoding issues as https://www.ibm.com/support/pages/conversion-character-differences-between-ccsid-037-and-ccsid-500 is not fully working anymore

const lookup = { '500': { '00': 'NUL', '01': 'SOH', '02': 'STX', '03': 'ETX', '04': 'SEL', '05': 'HT', '06': 'RNL', '07': 'DEL', '08': 'GE', '09': 'SPS', '0A': 'RPT', '0B': 'VT', '0C': '\f', // form feed '0D': '\r', // carriage return '0E': 'SO', '0F': 'SI', '10': 'DLE', '11': 'DC1', '12': 'DC2', '13': 'DC3', '14': 'RES/ENP', '15': '\n', '16': '\b', // backspace '17': 'POC', '18': 'CAN', '19': 'EM', '1A': 'UBS', '1B': 'CU1', '1C': 'IFS', '1D': 'IGS', '1E': 'IRS', '1F': 'ITB/IUS', '20': 'DS', '21': 'SOS', '22': 'FS', '23': '', '24': 'BYP/INP', '25': '\n', '26': 'ETB', '27': 'ESC', '28': 'SA', '29': 'SFE', '2A': 'SM/SW', '2B': 'CSP', '2C': 'MFA', '2D': 'ENQ', '2E': 'ACK', '2F': 'BEL', '30': '', // blank '31': '', // blank '32': 'SYN', '33': 'IR', '34': 'PP', '35': 'TRN', '36': 'NBS', '37': 'EOT', '38': 'SBS', '39': 'IT', '3A': 'RFF', '3B': 'CU3', '3C': 'DC4', '3D': 'NAK', '3E': '', // blank '3F': 'SUB', '40': ' ', // space '41': 'RSP', '42': 'â', '43': 'ä', '44': 'à', '45': 'á', '46': 'ã', '47': 'å', '48': 'ç', '49': 'ñ', '4A': '[', '4B': '.', '4C': '<', '4D': '(', '4E': '+', '4F': '!', '50': '&', '51': 'é', '52': 'ê', '53': 'ë', '54': 'è', '55': 'í', '56': 'î', '57': 'ï', '58': 'ì', '59': 'ß', '5A': ']', '5B': '$', '5C': '*', '5D': ')', '5E': ';', '5F': '^', '60': '-', '61': '/', '62': 'Â', '63': 'Ä', '64': 'À', '65': 'Á', '66': 'Ã', '67': 'Å', '68': 'Ç', '69': 'Ñ', '6A': '¦', '6B': ',', '6C': '%', '6D': '', '6E': '>', '6F': '?', '70': 'ø', '71': 'É', '72': 'Ê', '73': 'Ë', '74': 'È', '75': 'Í', '76': 'Î', '77': 'Ï', '78': 'Ì', '79': '', '7A': ':', '7B': '#', '7C': '@', '7D': '\'', '7E': '=', '7F': '"', '80': 'Ø', '81': 'a', '82': 'b', '83': 'c', '84': 'd', '85': 'e', '86': 'f', '87': 'g', '88': 'h', '89': 'i', '8A': '«', '8B': '»', '8C': 'ð', '8D': 'ý', '8E': 'Þ', '8F': '±', '90': '°', '91': 'j', '92': 'k', '93': 'l', '94': 'm', '95': 'n', '96': 'o', '97': 'p', '98': 'q', '99': 'r', '9A': 'ª', '9B': 'º', '9C': 'æ', '9D': '¸', '9E': 'Æ', '9F': '¤', 'A0': 'µ', 'A1': '~', 'A2': 's', 'A3': 't', 'A4': 'u', 'A5': 'v', 'A6': 'w', 'A7': 'x', 'A8': 'y', 'A9': 'z', 'AA': '¡', 'AB': '¿', 'AC': 'Ð', 'AD': 'Ý', 'AE': 'þ', 'AF': '®', 'B0': '¢', 'B1': '£', 'B2': '¥', 'B3': '·', 'B4': '©', 'B5': '§', 'B6': '¶', 'B7': '¼', 'B8': '½', 'B9': '¾', 'BA': '¬', 'BB': '|', 'BC': 'ä', 'BD': '"', 'BE': '´', 'BF': '×', 'C0': '{', 'C1': 'A', 'C2': 'B', 'C3': 'C', 'C4': 'D', 'C5': 'E', 'C6': 'F', 'C7': 'G', 'C8': 'H', 'C9': 'I', 'CA': '-', // SHY 'CB': 'ô', 'CC': 'ö', 'CD': 'ò', 'CE': 'ó', 'CF': 'õ', 'D0': '}', 'D1': 'J', 'D2': 'K', 'D3': 'L', 'D4': 'M', 'D5': 'N', 'D6': 'O', 'D7': 'P', 'D8': 'Q', 'D9': 'R', 'DA': '¹', 'DB': 'û', 'DC': 'ü', 'DD': 'ù', 'DE': 'ú', 'DF': 'ÿ', 'E0': '\\', 'E1': '÷', 'E2': 'S', 'E3': 'T', 'E4': 'U', 'E5': 'V', 'E6': 'W', 'E7': 'X', 'E8': 'Y', 'E9': 'Z', 'EA': '²', 'EB': 'Ô', 'EC': 'Ö', 'ED': 'Ò', 'EE': 'Ó', 'EF': 'Õ', 'F0': '0', 'F1': '1', 'F2': '2', 'F3': '3', 'F4': '4', 'F5': '5', 'F6': '6', 'F7': '7', 'F8': '8', 'F9': '9', 'FA': '³', 'FB': 'Û', 'FC': 'Ü', 'FD': 'Ù', 'FE': 'Ú', 'FF': 'EO' }, '37': { '00': 'NUL', '01': 'SOH', '02': 'STX', '03': 'ETX', '04': 'SEL', '05': 'HT', '06': 'RNL', '07': 'DEL', '08': 'GE', '09': 'SPS', '0A': 'RPT', '0B': 'VT', '0C': '\f', // form feed '0D': '\r', // carriage return '0E': 'SO', '0F': 'SI', '10': 'DLE', '11': 'DC1', '12': 'DC2', '13': 'DC3', '14': 'RES/ENP', '15': '\n', '16': '\b', // backspace '17': 'POC', '18': 'CAN', '19': 'EM', '1A': 'UBS', '1B': 'CU1', '1C': 'IFS', '1D': 'IGS', '1E': 'IRS', '1F': 'ITB/IUS', '20': 'DS', '21': 'SOS', '22': 'FS', '23': '_', '24': 'BYP/INP', '25': '\n', '26': 'ETB', '27': 'ESC', '28': 'SA', '29': 'SFE', '2A': 'SM/SW', '2B': 'CSP', '2C': 'MFA', '2D': 'ENQ', '2E': 'ACK', '2F': 'BEL', '30': '', // blank '31': '', // blank '32': 'SYN', '33': 'IR', '34': 'PP', '35': 'TRN', '36': 'NBS', '37': 'EOT', '38': 'SBS', '39': 'IT', '3A': 'RFF', '3B': 'CU3', '3C': 'DC4', '3D': 'NAK', '3E': '', // blank '3F': 'SUB', '40': ' ', // space '41': 'RSP', '42': 'â', '43': 'ä', '44': 'à', '45': 'á', '46': 'ã', '47': 'å', '48': 'ç', '49': 'ñ', '4A': '¢', '4B': '.', '4C': '<', '4D': '(', '4E': '+', '4F': '|', '50': '&', '51': 'é', '52': 'ê', '53': 'ë', '54': 'è', '55': 'í', '56': 'î', '57': 'ï', '58': 'ì', '59': 'ß', '5A': '!', '5B': '$', '5C': '*', '5D': ')', '5E': ';', '5F': '¬', '60': '-', '61': '/', '62': 'Â', '63': 'Ä', '64': 'À', '65': 'Á', '66': 'Ã', '67': 'Å', '68': 'Ç', '69': 'Ñ', '6A': '¦', '6B': ',', '6C': '%', '6D': '_', '6E': '>', '6F': '?', '70': 'ø', '71': 'É', '72': 'Ê', '73': 'Ë', '74': 'È', '75': 'Í', '76': 'Î', '77': 'Ï', '78': 'Ì', '79': '', '7A': ':', '7B': '#', '7C': '@', '7D': '\'', '7E': '=', '7F': '"', '80': 'Ø', '81': 'a', '82': 'b', '83': 'c', '84': 'd', '85': 'e', '86': 'f', '87': 'g', '88': 'h', '89': 'i', '8A': '«', '8B': '»', '8C': 'ð', '8D': 'ý', '8E': 'Þ', '8F': '±', '90': '°', '91': 'j', '92': 'k', '93': 'l', '94': 'm', '95': 'n', '96': 'o', '97': 'p', '98': 'q', '99': 'r', '9A': 'ª', '9B': 'º', '9C': 'æ', '9D': '¸', '9E': 'Æ', '9F': '¤', 'A0': 'µ', 'A1': '~', 'A2': 's', 'A3': 't', 'A4': 'u', 'A5': 'v', 'A6': 'w', 'A7': 'x', 'A8': 'y', 'A9': 'z', 'AA': '¡', 'AB': '¿', 'AC': 'Ð', 'AD': 'Ý', 'AE': 'þ', 'AF': '®', 'B0': '^', 'B1': '£', 'B2': '¥', 'B3': '·', 'B4': '©', 'B5': '§', 'B6': '¶', 'B7': '¼', 'B8': '½', 'B9': '¾', 'BA': '[', 'BB': ']', 'BC': 'ä', 'BD': '"', 'BE': '´', 'BF': '×', 'C0': '{', 'C1': 'A', 'C2': 'B', 'C3': 'C', 'C4': 'D', 'C5': 'E', 'C6': 'F', 'C7': 'G', 'C8': 'H', 'C9': 'I', 'CA': '-', // SHY 'CB': 'ô', 'CC': 'ö', 'CD': 'ò', 'CE': 'ó', 'CF': 'õ', 'D0': '}', 'D1': 'J', 'D2': 'K', 'D3': 'L', 'D4': 'M', 'D5': 'N', 'D6': 'O', 'D7': 'P', 'D8': 'Q', 'D9': 'R', 'DA': '¹', 'DB': 'û', 'DC': 'ü', 'DD': 'ù', 'DE': 'ú', 'DF': 'ÿ', 'E0': '\', 'E1': '÷', 'E2': 'S', 'E3': 'T', 'E4': 'U', 'E5': 'V', 'E6': 'W', 'E7': 'X', 'E8': 'Y', 'E9': 'Z', 'EA': '²', 'EB': 'Ô', 'EC': 'Ö', 'ED': 'Ò', 'EE': 'Ó', 'EF': 'Õ', 'F0': '0', 'F1': '1', 'F2': '2', 'F3': '3', 'F4': '4', 'F5': '5', 'F6': '6', 'F7': '7', 'F8': '8', 'F9': '9', 'FA': '³', 'FB': 'Û', 'FC': 'Ü', 'FD': 'Ù', 'FE': 'Ú', 'FF': 'EO' }