Skip to content

Commit 165eb69

Browse files
committed
vstr: Restore bytestr compatibility.
1 parent 42a5251 commit 165eb69

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

py/vstr.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ void vstr_add_byte(vstr_t *vstr, byte b) {
199199
}
200200

201201
void vstr_add_char(vstr_t *vstr, unichar c) {
202+
#if MICROPY_PY_BUILTINS_STR_UNICODE
202203
// TODO: Can this be simplified and deduplicated?
203204
// Is it worth just calling vstr_add_len(vstr, 4)?
204205
if (c < 0x80) {
@@ -233,6 +234,13 @@ void vstr_add_char(vstr_t *vstr, unichar c) {
233234
buf[2] = ((c >> 6) & 0x3F) | 0x80;
234235
buf[3] = (c & 0x3F) | 0x80;
235236
}
237+
#else
238+
byte *buf = (byte*)vstr_add_len(vstr, 1);
239+
if (buf == NULL) {
240+
return;
241+
}
242+
buf[0] = c;
243+
#endif
236244
}
237245

238246
void vstr_add_str(vstr_t *vstr, const char *str) {

0 commit comments

Comments
 (0)