From ea02c1c48a8a11aab78bd535d18fb17fdf62ae33 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Mon, 30 Aug 2021 08:45:56 -0400 Subject: msvc: Assume UTF8 source by default Currently every project that uses UTF8 for its source files must add '/utf-8' argument otherwise they don't work non-English locale MSVC. Since meson.build itself is assumed to be UTF8 by default, seems better to assume it for source files by default too. For example: - https://gitlab.freedesktop.org/gstreamer/gst-build/-/blob/master/meson.build#L62 - https://gitlab.gnome.org/GNOME/glib/-/blob/main/meson.build#L29 --- docs/markdown/snippets/msvc_utf8.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 docs/markdown/snippets/msvc_utf8.md (limited to 'docs/markdown') diff --git a/docs/markdown/snippets/msvc_utf8.md b/docs/markdown/snippets/msvc_utf8.md new file mode 100644 index 0000000..fb8763d --- /dev/null +++ b/docs/markdown/snippets/msvc_utf8.md @@ -0,0 +1,16 @@ +## MSVC compiler now assumes UTF-8 source code by default + +Every project that uses UTF-8 source files had to add manually `/utf-8` C/C++ +compiler argument for MSVC otherwise they wouldn't work on non-English locale. +Meson now switched the default to UTF-8 to be more consistent with all other +compilers. + +This can be overridden but using `/source-charset`: +```meson +if cc.get_id() == 'msvc' + add_project_arguments('/source-charset:.XYZ', language: ['c', 'cpp']) +endif +``` + +See Microsoft documentation for details: +https://docs.microsoft.com/en-us/cpp/build/reference/source-charset-set-source-character-set. -- cgit v1.1