1 parent 42a5251 commit 165eb69Copy full SHA for 165eb69
1 file changed
py/vstr.c
@@ -199,6 +199,7 @@ void vstr_add_byte(vstr_t *vstr, byte b) {
199
}
200
201
void vstr_add_char(vstr_t *vstr, unichar c) {
202
+#if MICROPY_PY_BUILTINS_STR_UNICODE
203
// TODO: Can this be simplified and deduplicated?
204
// Is it worth just calling vstr_add_len(vstr, 4)?
205
if (c < 0x80) {
@@ -233,6 +234,13 @@ void vstr_add_char(vstr_t *vstr, unichar c) {
233
234
buf[2] = ((c >> 6) & 0x3F) | 0x80;
235
buf[3] = (c & 0x3F) | 0x80;
236
237
+#else
238
+ byte *buf = (byte*)vstr_add_len(vstr, 1);
239
+ if (buf == NULL) {
240
+ return;
241
+ }
242
+ buf[0] = c;
243
+#endif
244
245
246
void vstr_add_str(vstr_t *vstr, const char *str) {
0 commit comments