| 1809 | }; |
| 1810 | |
| 1811 | PUGI__FN char_t* strconv_escape(char_t* s, gap& g) |
| 1812 | { |
| 1813 | char_t* stre = s + 1; |
| 1814 | |
| 1815 | switch (*stre) |
| 1816 | { |
| 1817 | case '#': // &#... |
| 1818 | { |
| 1819 | unsigned int ucsc = 0; |
| 1820 | |
| 1821 | if (stre[1] == 'x') // &#x... (hex code) |
| 1822 | { |
| 1823 | stre += 2; |
| 1824 | |
| 1825 | char_t ch = *stre; |
| 1826 | |
| 1827 | if (ch == ';') |
| 1828 | return stre; |
| 1829 | |
| 1830 | for (;;) |
| 1831 | { |
| 1832 | if (static_cast<unsigned int>(ch - '0') <= 9) |
| 1833 | ucsc = 16 * ucsc + (ch - '0'); |
| 1834 | else if (static_cast<unsigned int>((ch | ' ') - 'a') <= 5) |
| 1835 | ucsc = 16 * ucsc + ((ch | ' ') - 'a' + 10); |
| 1836 | else if (ch == ';') |
| 1837 | break; |
| 1838 | else // cancel |
| 1839 | return stre; |
| 1840 | |
| 1841 | ch = *++stre; |
| 1842 | } |
| 1843 | |
| 1844 | ++stre; |
| 1845 | } |
| 1846 | else // &#... (dec code) |
| 1847 | { |
| 1848 | char_t ch = *++stre; |
| 1849 | |
| 1850 | if (ch == ';') |
| 1851 | return stre; |
| 1852 | |
| 1853 | for (;;) |
| 1854 | { |
| 1855 | if (static_cast<unsigned int>(ch - '0') <= 9) |
| 1856 | ucsc = 10 * ucsc + (ch - '0'); |
| 1857 | else if (ch == ';') |
| 1858 | break; |
| 1859 | else // cancel |
| 1860 | return stre; |
| 1861 | |
| 1862 | ch = *++stre; |
| 1863 | } |
| 1864 | |
| 1865 | ++stre; |
| 1866 | } |
| 1867 | |
| 1868 | #ifdef PUGIXML_WCHAR_MODE |
no test coverage detected