MCPcopy Index your code
hub / github.com/MapServer/MapServer / msGetNextGlyph

Function msGetNextGlyph

mapstring.c:1830–1940  ·  view source on GitHub ↗

** Returns the next glyph in string and advances *in_ptr to the next ** character. ** ** If out_string is not NULL then the character (bytes) is copied to this ** buffer and null-terminated. out_string must be a pre-allocated buffer of ** at least 11 bytes. ** ** The function returns the number of bytes in this glyph. ** ** This function treats 3 types of glyph encodings: * - as an html entity,

Source from the content-addressed store, hash-verified

1828** U-04000000 U-7FFFFFFF: 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
1829*/
1830int msGetNextGlyph(const char **in_ptr, char *out_string)
1831{
1832 unsigned char in;
1833 int numbytes=0,unicode;
1834 int i;
1835
1836 in = (unsigned char)**in_ptr;
1837
1838 if (in == 0)
1839 return -1; /* Empty string */
1840 if((numbytes=msGetUnicodeEntity(*in_ptr,&unicode))>0) {
1841 if(out_string) {
1842 for(i=0;i<numbytes;i++) {
1843 out_string[i]=(*in_ptr)[i];
1844 }
1845 out_string[numbytes]='\0';
1846 }
1847 *in_ptr+=numbytes;
1848 return numbytes;
1849 }
1850 if (in < 0xC0)
1851 {/*
1852 * Handles properly formed UTF-8 characters between
1853 * 0x01 and 0x7F. Also treats \0 and naked trail
1854 * bytes 0x80 to 0xBF as valid characters representing
1855 * themselves.
1856 */
1857 /*goto end of loop to return just the char*/
1858 }
1859 else if (in < 0xE0)
1860 {
1861 if (((*in_ptr)[1]& 0xC0) == 0x80) {
1862 if(out_string) {
1863 out_string[0]=in;
1864 out_string[1]=(*in_ptr)[1];
1865 out_string[2]='\0';
1866 }
1867 *in_ptr+=2;
1868 return 2; /*110xxxxx 10xxxxxx*/
1869 }
1870 }
1871 else if (in < 0xF0)
1872 {
1873 if (((*in_ptr)[1]& 0xC0) == 0x80 && ((*in_ptr)[2]& 0xC0) == 0x80) {
1874 if(out_string) {
1875 out_string[0]=in;
1876 *in_ptr+=numbytes; out_string[1]=(*in_ptr)[1];
1877 out_string[2]=(*in_ptr)[2];
1878 out_string[3]='\0';
1879 }
1880 *in_ptr+=3;
1881 return 3; /* 1110xxxx 10xxxxxx 10xxxxxx */
1882 }
1883 }
1884 else if (in < 0xF8)
1885 {
1886 if (((*in_ptr)[1]& 0xC0) == 0x80 && ((*in_ptr)[2]& 0xC0) == 0x80
1887 && ((*in_ptr)[3]& 0xC0) == 0x80) {

Callers 4

msDrawTextLineFunction · 0.85
msGetNumGlyphsFunction · 0.85
msGetFirstLineFunction · 0.85
msWrapTextFunction · 0.85

Calls 1

msGetUnicodeEntityFunction · 0.85

Tested by

no test coverage detected