WordToChar()
Replace double with single characters
Syntax
WordToChar( <cDoubleCharacterSearchString>, <cString>, <cSingleCharacterReplaceString> ) -> cString
Arguments
<cDoubleCharacterSearchString> Designates multiple 2-byte sequences which are exchanged for corresponding individual characters from the <cSingleCharacter ReplaceString>.
<cString> Designates the character string within which 2-byte sequences are exchanged for individual characters.
<cSingleCharacterReplaceString> Designates a sequence of individual characters which correspond to 2-byte sequences in <cDoubleCharacterSearchString> for replacement within <cString>.
Returns
WordToChar() returns the modified character string.
Description
When you use SOUNDEX algorithms, sequences of two characters must often be exchanged for a single other character. WordToChar() makes this process extremely simple and quick. The function processes the <cString> in 1-byte steps. The behavior after exchanging a sequence for a character is determined by CSetAtMuPa(). If CSetAtMuPa is .F., the search for more sequences continues after the exchanged characters. If CSetAtMuPa is .T., the search for more sequences continues and includes the exchanged characters.
Notes
. The term “word” is not used here in the textual sense, but rather as it is used in assembler programming. A “word” consists of units of 16 bits, or more precisely, 2 bytes. . <cCharacterlist> can be shorter than <cDoubleCharacterList>. When this occurs, the function exchanges the sequences in <cDoubleCharacterList> that do not have corresponding sequences in <cCharacterlist> for the last sequence in <cDoubleCharacterList>.
Examples
. This example shows a simple replacement: ? WordToChar("aa", "Xaaaa", "a") // "Xaa" . This example shows WORDTOCHAR() in conjunction with CSetAtMuPa(): CSetAtMuPa(.F.) // Multi pass off ? WordToChar("aa", "Xaaaa", "a") // "Xaa" CSetAtMuPa(.T.) // Multi pass on ? WordToChar("aa", "Xaaaa", "a") // "Xa"
Compliance
WordToChar() is compatible with CT3’s WordToChar().
Platforms
All
Files
Source is wordtoch.c, library is libct.
Seealso
CSetAtMuPa(), CharRepl(), WordRepl()
Pingback: Harbour String Functions | Viva Clipper !
Pingback: Harbour All Functions – W | Viva Clipper !