Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

Hex to Character Conversion Revisited

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hex to Character Conversion Revisited

    ** This thread discusses the article: Hex to Character Conversion Revisited **
    ** This thread discusses the Content article: Hex to Character Conversion Revisited **This is a discussion about Hex to Character Conversion Revisited.

    Click here for the article.


  • #2
    Hex to Character Conversion Revisited

    ** This thread discusses the article: Hex to Character Conversion Revisited **
    When converting from char to hex, the source length should be twice the Char input length, not the Char input length. Jim

    Comment


    • #3
      Hex to Character Conversion Revisited

      ** This thread discusses the article: Hex to Character Conversion Revisited **
      In the article you state: cvthc converts from character value to hexadecimal text (that is, from 'A' to X'C1'). I feel that this may be incorrect. 'A' is the same as x'C1' Is it not correct to state: ... (that is, from 'A' to x'FCF1' or 'C1')

      Comment


      • #4
        Hex to Character Conversion Revisited

        ** This thread discusses the article: Hex to Character Conversion Revisited **
        I have a need to convert EBCDIC characters to ASCII Hex (A123 = x'41313233'). Can these routines convert among CCSID's? Any other way to do this other than Select/When?

        Comment


        • #5
          Hex to Character Conversion Revisited

          ** This thread discusses the article: Hex to Character Conversion Revisited **
          You can use iconv() to convert between CCSIDs and then call cvthc and cvtch to convert between character and hex.

          Comment


          • #6
            Hex to Character Conversion Revisited

            ** This thread discusses the article: Hex to Character Conversion Revisited **
            Thanks Bob. The cvtch and cvthc functions only work on 0-9, A-F. I need to be able to convert the entire character set, including non-alphanumeric characters (i.e. "-/.#" etc.). Any suggestions?

            Comment


            • #7
              Hex to Character Conversion Revisited

              ** This thread discusses the article: Hex to Character Conversion Revisited **
              I don't want to sound rude, but you're missing something. You can convert any of the 256 characters to their 2-character hexadecimal equivalent and back again. There is no restrictions.

              Comment


              • #8
                Hex to Character Conversion Revisited

                ** This thread discusses the article: Hex to Character Conversion Revisited **
                Bob, Thanks very much, yet again, for this valuable technique. I would like to utilize it now in my auditing. Could you please give a example of the Calc specs used to perform this conversion? I need to take any variable and convert it, as in a program dump which shows both Character and Hexidecimal for the variable. Many, many Thanks, Paul H. Harkins

                Comment


                • #9
                  Hex to Character Conversion Revisited

                  ** This thread discusses the article: Hex to Character Conversion Revisited **
                  Bob, how can I specify a codepage (CCSID) there ? I ask because different codepages mean different characters. For example the hex value X'7C' means in codepage 1141 the value "§" and in codepage 1153 the value "@". BR, Konni

                  Comment


                  • #10
                    Hex to Character Conversion Revisited

                    ** This thread discusses the article: Hex to Character Conversion Revisited **
                    The meaning of the data doesn't matter to the API. If you have a byte with the value x'7C', the toHex function will give '7C', no matter how x'7C' might appear if you display it.

                    Comment


                    • #11
                      Hex to Character Conversion Revisited

                      ** This thread discusses the article: Hex to Character Conversion Revisited **
                      Simple example attached...
                      Code

                      Comment


                      • #12
                        Hex to Character Conversion Revisited

                        ** This thread discusses the article: Hex to Character Conversion Revisited **
                        Phil, Many thanks for the complete example. The convert to and from Hex routines would make great BIFs for IBM in RPGLE. Best Regards, Paul H. Harkins

                        Comment


                        • #13
                          Hex to Character Conversion Revisited

                          ** This thread discusses the article: Hex to Character Conversion Revisited **
                          Normally you convert to character from hex and then convert the characters to the CCSID of your choice. Use iconv() to convert the CCSID.

                          Comment


                          • #14
                            Hex to Character Conversion Revisited

                            ** This thread discusses the article: Hex to Character Conversion Revisited **
                            I am trying to go from a 128 hex field to a 64 character field. I assume I would only need part of the code you offered (see below)? What I don't understand is how the fields: szCharVal, szHexVal, nSrcLen and len, inCharVal, ouCharVal, inHexVal, ouHexVal relate to each other? What field would I plug in the 128 hex field and what field would return the 64 character field? THank you.
                            Code

                            Comment


                            • #15
                              Hex to Character Conversion Revisited

                              ** This thread discusses the article: Hex to Character Conversion Revisited **
                              Did you ask this same question on my rpgiv.com/forum recently? Anyway, the way the two built-in work is as follows: cvtch converts to character from hex. cvthc converts to hex from character. The first parameter of both built-ins is the target. Therefore, parm 1 is the resulting character value in cvtch, and is the resulting hex value in in cvthc. The second parm is obviously the opposite value. The third parameter is ALWAYS the length of the hex data. That is the number of hex "values" or symbols (two for each character being converted) being converted.

                              Comment

                              Working...
                              X