Ctrans (function)

Description

Transforms a string from UTF-8 to ASCII, effectively replacing all special characters and accents not managed in ASCII by their equivalent. If 3 parameters are used,  each specified character (IN) is replaced by the specified character (OUT).

Syntax

ctrans( STRING )
ctrans( STRING, STRING_IN, STRING_OUT )

Examples

ctrans("transforme les caractères d'une chaîne, codés sur 8 bits, en caractères codés sur 7 bits")
# -> "transforme les caracteres d'une chaine, codes sur 8 bits, en caracteres codes sur 7 bits"
 
ctrans ("àèìòùëïüâêîôûéç")
# -> "aeioueiuaeiouec"
 
ctrans(P_PATH, "/", "\")
# -> Replaces all slashes by backslashes in a file path

ctrans("TEST NUMBER \ONE!", "!\", ".")
# -> "TEST NUMBER ONE."

Note

The function replaces:

  • The accentuated characters by the equivalent character without accent.
  • The non-printable characters by a space.
  • The semigraphic characters used for arrays by “!”, “+”, or “-“.
Scroll to Top