WordToChar()

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()

2 responses to “WordToChar()

  1. Pingback: Harbour String Functions | Viva Clipper !

  2. Pingback: Harbour All Functions – W | Viva Clipper !

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.