summaryrefslogtreecommitdiffstatshomepage
path: root/py/misc.h
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-01-28 14:07:11 +0000
committerDamien George <damien.p.george@gmail.com>2015-01-28 14:07:11 +0000
commit16677ce311fd70162cc9f7cfe2ab97461df765fc (patch)
treeb6c76957d31774814f3a8203ab9035f910107f74 /py/misc.h
parent0ecd5988a24aaa72415d83961327fc034cfe64a2 (diff)
downloadmicropython-16677ce311fd70162cc9f7cfe2ab97461df765fc.tar.gz
micropython-16677ce311fd70162cc9f7cfe2ab97461df765fc.zip
py: Be more precise about unicode type and disabled unicode behaviour.
Diffstat (limited to 'py/misc.h')
-rw-r--r--py/misc.h10
1 files changed, 9 insertions, 1 deletions
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 <stdint.h> // 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);