Implement read.
This commit is contained in:
parent
286f9c75b9
commit
b6581e98d7
@ -143,6 +143,7 @@ int guac_utf8_read(const char* utf8, int length, int* codepoint) {
|
|||||||
unsigned char initial;
|
unsigned char initial;
|
||||||
int bytes;
|
int bytes;
|
||||||
int result;
|
int result;
|
||||||
|
int i;
|
||||||
|
|
||||||
/* If not even one byte, cannot read */
|
/* If not even one byte, cannot read */
|
||||||
if (length <= 0)
|
if (length <= 0)
|
||||||
@ -185,7 +186,11 @@ int guac_utf8_read(const char* utf8, int length, int* codepoint) {
|
|||||||
if (bytes > length)
|
if (bytes > length)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* STUB: Read. */
|
/* Read trailing bytes, if any */
|
||||||
|
for (i=1; i<bytes; i++) {
|
||||||
|
result <<= 6;
|
||||||
|
result |= *(utf8++) & 0x3F;
|
||||||
|
}
|
||||||
|
|
||||||
*codepoint = result;
|
*codepoint = result;
|
||||||
return bytes;
|
return bytes;
|
||||||
|
Loading…
Reference in New Issue
Block a user