mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-11 17:13:37 +02:00
String literals for UTF-8 language names using octal escapes only...
... Leaving absolutely no doubt about the portability. New Perl script in locale emits the required C++ source when LanguageNames.txt is updated.
This commit is contained in:
23
locale/CeePlusPlusifyLanguageNames.pl
Executable file
23
locale/CeePlusPlusifyLanguageNames.pl
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/perl
|
||||
# Take LangugeNames.txt and write C++ string literals to standard out,
|
||||
# which describe the UTF-8 byte sequence using only the basic coding
|
||||
# character set.
|
||||
# Copy and paste that over the table of strings in src/Languages.cpp.
|
||||
|
||||
open LANGUAGES, "LanguageNames.txt" or die "Can't open LanguageNames.txt: $!\n";
|
||||
while( <LANGUAGES> ) {
|
||||
chop;
|
||||
print "\"";
|
||||
@codes = unpack 'C*';
|
||||
@newCodes = ();
|
||||
for $code (@codes) {
|
||||
if ($code <= ord 'z') {
|
||||
push @newCodes, $code;
|
||||
}
|
||||
else {
|
||||
push @newCodes, unpack('C*', sprintf("\\%03o", $code));
|
||||
}
|
||||
}
|
||||
print pack 'C*', @newCodes;
|
||||
print "\",\n";
|
||||
}
|
Reference in New Issue
Block a user