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

Function str_utf8_encode

server/src/system.c:1888–1919  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1886}
1887
1888int str_utf8_encode(char *ptr, int chr)
1889{
1890 /* encode */
1891 if(chr <= 0x7F)
1892 {
1893 ptr[0] = (char)chr;
1894 return 1;
1895 }
1896 else if(chr <= 0x7FF)
1897 {
1898 ptr[0] = 0xC0|((chr>>6)&0x1F);
1899 ptr[1] = 0x80|(chr&0x3F);
1900 return 2;
1901 }
1902 else if(chr <= 0xFFFF)
1903 {
1904 ptr[0] = 0xE0|((chr>>12)&0x0F);
1905 ptr[1] = 0x80|((chr>>6)&0x3F);
1906 ptr[2] = 0x80|(chr&0x3F);
1907 return 3;
1908 }
1909 else if(chr <= 0x10FFFF)
1910 {
1911 ptr[0] = 0xF0|((chr>>18)&0x07);
1912 ptr[1] = 0x80|((chr>>12)&0x3F);
1913 ptr[2] = 0x80|((chr>>6)&0x3F);
1914 ptr[3] = 0x80|(chr&0x3F);
1915 return 4;
1916 }
1917
1918 return 0;
1919}
1920
1921int str_utf8_decode(const char **ptr)
1922{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected