comparison Core/Toolbox.cpp @ 3328:f0c92ecd09c8

merge
author Alain Mazy <alain@mazy.be>
date Thu, 21 Mar 2019 11:44:21 +0100
parents b21d4cc8e5d1 87396c571109
children 2a38e00a0638
comparison
equal deleted inserted replaced
3327:0f17fd02d401 3328:f0c92ecd09c8
1819 if (position >= utf8.size()) 1819 if (position >= utf8.size())
1820 { 1820 {
1821 throw OrthancException(ErrorCode_ParameterOutOfRange); 1821 throw OrthancException(ErrorCode_ParameterOutOfRange);
1822 } 1822 }
1823 1823
1824 const uint8_t* buffer = reinterpret_cast<const uint8_t*>(utf8.c_str()); 1824 assert(sizeof(uint8_t) == sizeof(char));
1825 const uint8_t* buffer = reinterpret_cast<const uint8_t*>(utf8.c_str()) + position;
1825 1826
1826 if ((buffer[0] & MASK_IS_1_BYTE) == TEST_IS_1_BYTE) 1827 if ((buffer[0] & MASK_IS_1_BYTE) == TEST_IS_1_BYTE)
1827 { 1828 {
1828 length = 1; 1829 length = 1;
1829 unicode = buffer[0] & ~MASK_IS_1_BYTE; 1830 unicode = buffer[0] & ~MASK_IS_1_BYTE;
1862 unicode = (a << 18) | (b << 12) | (c << 6) | d; 1863 unicode = (a << 18) | (b << 12) | (c << 6) | d;
1863 } 1864 }
1864 else 1865 else
1865 { 1866 {
1866 // This is not a valid UTF-8 encoding 1867 // This is not a valid UTF-8 encoding
1867 throw OrthancException(ErrorCode_BadFileFormat); 1868 throw OrthancException(ErrorCode_BadFileFormat, "Invalid UTF-8 string");
1868 } 1869 }
1869 } 1870 }
1870 } 1871 }
1871 1872
1872 1873