Xlate$: Difference between revisions

From BR Wiki
Jump to navigation Jump to search
m (moved XLATE$ to Xlate$ over redirect)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
The '''Xlate$''' [[internal function]] returns A$ translated using B$ as a translation table. If X is specified, it starts in position X of string A$; otherwise it starts at the first character of A$.
The '''Xlate$''' [[internal function]] returns a string translated using a second string as a translation table. If a position is specified, it starts at that position of the first string; otherwise it starts at the first character.


  Xlate$(A$,B$[,X])
  XLATE$(<string>,<translation string>[,<position>])


====Comments and Examples====
====Comments and Examples====
XLATE$(A$,B$,X)
Whenever [[ASCII]] character [[null]] (CHR$(0)) is found in A$, it is replaced by the first character in B$. ASCII character [[Ctrl-A]] (CHR$(1)) is replaced by the second character in B$. In other words, ASCII character N-1 is replaced by the Nth character of B$. ASCII values greater than [[LEN]](B$)-1 are not changed.
Whenever [[ASCII]] character [[null]] (CHR$(0)) is found in A$, it is replaced by the first character in B$. ASCII character [[Ctrl-A]] (CHR$(1)) is replaced by the second character in B$. In other words, ASCII character N-1 is replaced by the Nth character of B$. ASCII values greater than [[LEN]](B$)-1 are not changed.


Line 9: Line 12:


In line 100, Y$ will be a translation of X$ using Table$. For example, spaces (ASCII value 32) will be replaced by Table$(33:33), the character in the 33rd position of Table$.
In line 100, Y$ will be a translation of X$ using Table$. For example, spaces (ASCII value 32) will be replaced by Table$(33:33), the character in the 33rd position of Table$.
====UTF-8 / UTF8 Support====
If the first 7 bytes of the table consists of STR2UTF or UTF2STR (case insensitive) then conversion to or from UTF-8 takes place.
XLATE$(A$,"str2utf") ! converts A$ to UTF-8


====Related Functions====
====Related Functions====

Latest revision as of 16:42, 18 March 2018

The Xlate$ internal function returns a string translated using a second string as a translation table. If a position is specified, it starts at that position of the first string; otherwise it starts at the first character.

XLATE$(<string>,<translation string>[,<position>])

Comments and Examples

XLATE$(A$,B$,X)

Whenever ASCII character null (CHR$(0)) is found in A$, it is replaced by the first character in B$. ASCII character Ctrl-A (CHR$(1)) is replaced by the second character in B$. In other words, ASCII character N-1 is replaced by the Nth character of B$. ASCII values greater than LEN(B$)-1 are not changed.

00100 LET Y$=XLATE$(X$,TABLE$)

In line 100, Y$ will be a translation of X$ using Table$. For example, spaces (ASCII value 32) will be replaced by Table$(33:33), the character in the 33rd position of Table$.

UTF-8 / UTF8 Support

If the first 7 bytes of the table consists of STR2UTF or UTF2STR (case insensitive) then conversion to or from UTF-8 takes place.

XLATE$(A$,"str2utf") ! converts A$ to UTF-8

Related Functions

During input or output operations, data can be translated (for example from ASCII to EBCDIC) by using the TRANSLATE= parameter in the OPEN statement.