GNOME Bugzilla – Bug 767708
Compilation failed when use utf-8 variable name
Last modified: 2017-11-12 18:22:37 UTC
I use this page's Basic Sample. https://wiki.gnome.org/Projects/Vala/GTKSample using Gtk; int main (string[] args) { Gtk.init (ref args); var window = new Window (); window.title = "First GTK+ Program"; window.border_width = 10; window.window_position = WindowPosition.CENTER; window.set_default_size (350, 70); window.destroy.connect (Gtk.main_quit); var button = new Button.with_label ("Click me!"); button.clicked.connect (() => { button.label = "Thank you"; }); window.add (button); window.show_all (); Gtk.main (); return 0; } when I change 'window' to '窗口' or 'tm_窗口', the code will compilation failed. It says "syntax error, unexpected character". I checked the code. this error happened at line 1207. ------------------code begin-------------------- default: unichar u = ((string) current).get_char_validated ((long) (end - current)); if (u != (unichar) (-1)) { current += u.to_utf8 (null); Report.error (get_source_reference (0), "syntax error, unexpected character"); } else { current++; Report.error (get_source_reference (0), "invalid UTF-8 character"); } column++; return read_token (out token_begin, out token_end); ------------------code end------------------------ It seems that vala support UTF-8 character while I got error here.
Vala expects source files to be encoded as UTF-8. However, identifiers are restricted to a subset of ASCII (alphanumeric and underscore). This is not a defect. Lifting this restriction could lead to various issues, depending on the C compiler, GLib, and other tools. I also don't currently expect a big demand for this, given that Vala keywords and library APIs would stay in English.