| 14 | } |
| 15 | |
| 16 | int64_t cpp::encoding::Ascii::encode(const String& string, View<uint8_t> buffer) |
| 17 | { |
| 18 | if (null() == string) |
| 19 | { |
| 20 | hx::NullReference("String", false); |
| 21 | } |
| 22 | |
| 23 | if (string.isUTF16Encoded()) |
| 24 | { |
| 25 | hx::Throw(HX_CSTRING("String cannot be encoded to ASCII")); |
| 26 | } |
| 27 | |
| 28 | auto src = cpp::marshal::View<char>(string.raw_ptr(), string.length).reinterpret<uint8_t>(); |
| 29 | |
| 30 | if (src.tryCopyTo(buffer)) |
| 31 | { |
| 32 | return src.length; |
| 33 | } |
| 34 | else |
| 35 | { |
| 36 | return hx::Throw(HX_CSTRING("Buffer too small")); |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | String cpp::encoding::Ascii::decode(View<uint8_t> view) |
| 41 | { |
nothing calls this directly
no test coverage detected