summaryrefslogtreecommitdiff
path: root/fluid/code.cxx
diff options
context:
space:
mode:
authorMatthias Melcher <git@matthiasm.com>2021-12-17 21:15:04 +0100
committerMatthias Melcher <github@matthiasm.com>2021-12-17 21:28:23 +0100
commitb490ce3463e9008d03224feb44c8b365a8e21954 (patch)
tree53065e0c5ba4fa19876ff44e3986d66d1b1feef6 /fluid/code.cxx
parent6efc997a02e3125290f9b0883a1a880b9e14bd4b (diff)
STR 3355: allow Unicode UTF-8 in source code
This includes changes in the UI in Project Settings.
Diffstat (limited to 'fluid/code.cxx')
-rw-r--r--fluid/code.cxx12
1 files changed, 12 insertions, 0 deletions
diff --git a/fluid/code.cxx b/fluid/code.cxx
index a28961028..e9af1fd53 100644
--- a/fluid/code.cxx
+++ b/fluid/code.cxx
@@ -269,6 +269,18 @@ void write_cstring(const char *s, int length) {
linelength++;
break;
}
+ // if the UTF-8 option is checked, write unicode characters verbatim
+ if (utf8_in_src && (c&0x80)) {
+ if ((c&0x40)) {
+ // This is the first character in a utf-8 sequence (0b11......).
+ // A line break would be ok here. Do not put linebreak in front of
+ // following characters (0b10......)
+ if (linelength >= 78) {fputs("\\\n",code_file); linelength = 0;}
+ }
+ putc(c, code_file);
+ linelength++;
+ break;
+ }
// otherwise we must print it as an octal constant:
c &= 255;
if (c < 8) {