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#L29pull/9202/head
parent
22c38a0006
commit
ea02c1c48a
7 changed files with 70 additions and 2 deletions
@ -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. |
@ -0,0 +1,7 @@ |
||||
#include <stdio.h> |
||||
|
||||
int main(int argc, char *argcv[]) |
||||
{ |
||||
printf("This is ISO-8859-1 encoded é\n"); |
||||
return 0; |
||||
} |
@ -0,0 +1,15 @@ |
||||
project('charset', 'c') |
||||
|
||||
cc = meson.get_compiler('c') |
||||
|
||||
if cc.get_id() != 'msvc' |
||||
error('MESON_SKIP_TEST requires MSVC.') |
||||
endif |
||||
|
||||
executable('utf8', 'utf8.c') |
||||
|
||||
if get_option('test-failure') |
||||
executable('iso-8859-1', 'iso-8859-1.c') |
||||
else |
||||
executable('iso-8859-1', 'iso-8859-1.c', c_args: '/source-charset:.850') |
||||
endif |
@ -0,0 +1 @@ |
||||
option('test-failure', type: 'boolean', value: false) |
@ -0,0 +1,7 @@ |
||||
#include <stdio.h> |
||||
|
||||
int main(int argc, char *argcv[]) |
||||
{ |
||||
printf("This is UTF-8 encoded é\n"); |
||||
return 0; |
||||
} |
Loading…
Reference in new issue