ASCII to CHAR

Author: dennis.vorst@uniface.com (Dennis Vorst)

Hi Is there a way in Uniface to convert a number to its ASCII equivalent? For instance 65 into the capital A. And vice versa.

4 Comments

  1. For ASCII value to character you can use $string Can't type the syntax here because it gets translated by the forum software so please look it up in the uLibrary.


    Author: Theo Neeskens (tneeskens@itblockz.nl)
  2. You could also use $encode/$decode - although then you'll deal with HEX values (e.g. 65 = 0x41).

    • HEX to CHAR: $encode("USTRING", $decode("HEX", "41")) => "A" ; please note that $decode will return RAW data and we therfore have to convert it to a string using $encode("USTRING")
    • CHAR to HEX: $encode("HEX", "A") => "41"

    In case you need a numeric value then you additionally have to write a little conversion routine for numeric to HEX and HEX to numeric.


    Author: diseli (daniel.iseli@uniface.com)
  3. Hello, There is also the undocumented function $tometa().

    A = $tometa(65)

    Author: Philippe (philippe.grangeray@agfa.com)
  4. diseli said You could also use $encode/$decode - although then you'll deal with HEX values (e.g. 65 = 0x41).
    • HEX to CHAR: $encode("USTRING", $decode("HEX", "41")) => "A" ; please note that $decode will return RAW data and we therfore have to convert it to a string using $encode("USTRING")
    • CHAR to HEX: $encode("HEX", "A") => "41"
    In case you need a numeric value then you additionally have to write a little conversion routine for numeric to HEX and HEX to numeric.

    Just a quick note: $encode/$decode will only only work with UTF-8 - the output of $decode is UTF-8 and the input of $encode is treated as UTF-8.


    Author: diseli (daniel.iseli@uniface.com)