Back to index

php5  5.3.10
Functions
utf8_to_utf16.c File Reference
#include "utf8_to_utf16.h"
#include "utf8_decode.h"

Go to the source code of this file.

Functions

int utf8_to_utf16 (unsigned short w[], char p[], int length)

Function Documentation

int utf8_to_utf16 ( unsigned short  w[],
char  p[],
int  length 
)

Definition at line 33 of file utf8_to_utf16.c.

{
    int c;
    int the_index = 0;
    json_utf8_decode utf8;
    
    utf8_decode_init(&utf8, p, length);
    for (;;) {
        c = utf8_decode_next(&utf8);
        if (c < 0) {
            return (c == UTF8_END) ? the_index : UTF8_ERROR;
        }
        if (c < 0x10000) {
            w[the_index] = (unsigned short)c;
            the_index += 1;
        } else {
            c -= 0x10000;
            w[the_index] = (unsigned short)(0xD800 | (c >> 10));
            the_index += 1;
            w[the_index] = (unsigned short)(0xDC00 | (c & 0x3FF));
            the_index += 1;
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function: