CHARSHL()
Process each character in a string with bitwise SHIFT LEFT operation
Syntax
CHARSHL( <[@]cString>, <nBitsToSHL> ) --> cSHLString
Arguments
<[@]cString> string to be processed
<nBitsToSHL> number of bit positions to be shifted to the left
Returns
<cSHLString> string with bitwise shifted left characters
Description
The CHARSHL() function constructs a new string from the string passed as parameter. To do this, it performs a bitwise SHIFT LEFT (SHL) operation to the characters of the string and places a character in the resulting string whose ASCII value equals to the result of that operation. Be aware that bits shifted out of the byte are lost. If you need a bit rotation, use the CHARRLL() function instead. If the string is passed by reference, the resulting string is stored in <cString>, too. By setting the CSETREF()-switch to .T., the return value can be omitted.
Examples
? charshl( Chr(1)+Chr(2)+Chr(4)+Chr(8)+Chr(16)+Chr(32)+Chr(64)+Chr(128), 3 ) // --> Chr(8)+Chr(16)+Chr(32)+Chr(64)+Chr(128)+Chr(0)+Chr(0)+Chr(0)
Tests
charshl( Chr(1)+Chr(2)+Chr(4)+Chr(8)+Chr(16)+Chr(32)+Chr(64)+Chr(128), 3 ) == Chr(8)+Chr(16)+Chr(32)+Chr(64)+Chr(128)+Chr(0)+Chr(0)+Chr(0)
Compliance
CHARSHL() is a new function that is only available in Harbour’s CT3 lib.
Platforms
All
Files
Source is charop.c, library is ct3.
Seealso
CHARADD(), CHARSUB(), CHARAND(), CHAROR(), CHARXOR(), CHARNOT(), CHARSHR(), CHARRLL(), CHARRLR(), CSETREF()
Pingback: Harbour String Functions | Viva Clipper !
Pingback: Harbour All Functions – C | Viva Clipper !