CHARSHR()
Process each character in a string with bitwise SHIFT RIGHT operation
- Syntax
-
- CHARSHR (<[@]cString>, <nBitsToSHR> ) --> cSHRString
- Arguments
-
- <[@]cString> string to be processed <nBitsToSHR> number of bit positions to be shifted to the right
- Returns
-
- <cSHRString> string with bitwise shifted right characters
- Description
-
- The CHARSHR() function constructs a new string from the string passed as parameter. To do this, it performs a bitwise SHIFT RIGHT (SHR) 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 CHARRLR() 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
? charshr (chr(1)+chr(2)+chr(4)+chr(8)+chr(16)+chr(32)+chr(64)+chr(128), 3)
--> chr(0)+chr(0)+chr(0)+chr(1)+chr(2)+chr(4)+chr(8)+chr(16)
Tests
charshr (chr(1)+chr(2)+chr(4)+chr(8)+chr(16)+chr(32)+chr(64)+chr(128), 3) == chr(0)+chr(0)+chr(0)+chr(1)+chr(2)+chr(4)+chr(8)+chr(16)
- Status
- Ready
- Compliance
-
- CHARSHR() is a new function that is only available in Harbour's CT3 lib.
- Platforms
-
- All
- Files
-
- Source is charop.c, library is ct3.
- See Also