MCPcopy Create free account
hub / github.com/cppla/ServerStatus / str_utf8_forward

Function str_utf8_forward

server/src/system.c:1857–1886  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1855}
1856
1857int str_utf8_forward(const char *str, int cursor)
1858{
1859 const char *buf = str + cursor;
1860 if(!buf[0])
1861 return cursor;
1862
1863 if((*buf&0x80) == 0x0) /* 0xxxxxxx */
1864 return cursor+1;
1865 else if((*buf&0xE0) == 0xC0) /* 110xxxxx */
1866 {
1867 if(!buf[1]) return cursor+1;
1868 return cursor+2;
1869 }
1870 else if((*buf & 0xF0) == 0xE0) /* 1110xxxx */
1871 {
1872 if(!buf[1]) return cursor+1;
1873 if(!buf[2]) return cursor+2;
1874 return cursor+3;
1875 }
1876 else if((*buf & 0xF8) == 0xF0) /* 11110xxx */
1877 {
1878 if(!buf[1]) return cursor+1;
1879 if(!buf[2]) return cursor+2;
1880 if(!buf[3]) return cursor+3;
1881 return cursor+4;
1882 }
1883
1884 /* invalid */
1885 return cursor+1;
1886}
1887
1888int str_utf8_encode(char *ptr, int chr)
1889{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected