After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 767708 - Compilation failed when use utf-8 variable name
Compilation failed when use utf-8 variable name
Status: RESOLVED NOTABUG
Product: vala
Classification: Core
Component: Parser
0.32.x
Other Linux
: Normal major
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2016-06-16 02:23 UTC by hummerstudio
Modified: 2017-11-12 18:22 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description hummerstudio 2016-06-16 02:23:03 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.
Comment 1 Jürg Billeter 2016-06-16 12:01:30 UTC
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.