From 16677ce311fd70162cc9f7cfe2ab97461df765fc Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 28 Jan 2015 14:07:11 +0000 Subject: py: Be more precise about unicode type and disabled unicode behaviour. --- py/misc.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'py/misc.h') diff --git a/py/misc.h b/py/misc.h index 42d30055f9..b9ef68badd 100644 --- a/py/misc.h +++ b/py/misc.h @@ -92,7 +92,15 @@ size_t m_get_peak_bytes_allocated(void); /** unichar / UTF-8 *********************************************/ -typedef int unichar; // TODO +#if MICROPY_PY_BUILTINS_STR_UNICODE +#include // only include if we need it +// with unicode enabled we need a type which can fit chars up to 0x10ffff +typedef uint32_t unichar; +#else +// without unicode enabled we can only need to fit chars up to 0xff +// (on 16-bit archs uint is 16-bits and more efficient than uint32_t) +typedef uint unichar; +#endif unichar utf8_get_char(const byte *s); const byte *utf8_next_char(const byte *s); -- cgit v1.2.3