| 5886 | } |
| 5887 | |
| 5888 | Vector<uint8_t> String::to_utf8_buffer() const { |
| 5889 | const String *s = this; |
| 5890 | if (s->is_empty()) { |
| 5891 | return Vector<uint8_t>(); |
| 5892 | } |
| 5893 | CharString charstr = s->utf8(); |
| 5894 | |
| 5895 | Vector<uint8_t> retval; |
| 5896 | size_t len = charstr.length(); |
| 5897 | retval.resize_uninitialized(len); |
| 5898 | uint8_t *w = retval.ptrw(); |
| 5899 | memcpy(w, charstr.ptr(), len); |
| 5900 | |
| 5901 | return retval; |
| 5902 | } |
| 5903 | |
| 5904 | Vector<uint8_t> String::to_utf16_buffer() const { |
| 5905 | const String *s = this; |