blob: c6c39833de284e8aa4f8d05c8ebefc4adbcaec0a [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001/*
2 * Simplistic program to correct SJIS inside strings. When a trail byte is a
3 * backslash it needs to be doubled.
4 * Public domain.
5 */
6#include <stdio.h>
7#include <string.h>
8
9 int
Bram Moolenaard14e00e2016-01-31 17:30:51 +010010main(int argc, char **argv)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011{
12 char buffer[BUFSIZ];
13 char *p;
14
15 while (fgets(buffer, BUFSIZ, stdin) != NULL)
16 {
17 for (p = buffer; *p != 0; p++)
18 {
Bram Moolenaard1d037e2018-06-24 18:04:50 +020019 if (strncmp(p, "charset=utf-8", 13) == 0
20 || strncmp(p, "charset=UTF-8", 13) == 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +000021 {
RestorerZe2146922023-11-23 20:58:32 +010022 fputs("charset=CP932", stdout);
Bram Moolenaare6ae6222013-05-21 21:01:10 +020023 p += 12;
Bram Moolenaar071d4272004-06-13 20:20:40 +000024 }
Bram Moolenaar983c4e92014-11-12 13:07:53 +010025 else if (strncmp(p, "# Original translations", 23) == 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +000026 {
RestorerZe2146922023-11-23 20:58:32 +010027 fputs("# Generated from ja.po, DO NOT EDIT.", stdout);
Bram Moolenaar071d4272004-06-13 20:20:40 +000028 while (p[1] != '\n')
29 ++p;
30 }
31 else if (*(unsigned char *)p == 0x81 && p[1] == '_')
32 {
33 putchar('\\');
34 ++p;
35 }
36 else
37 {
38 if (*p & 0x80)
39 {
40 putchar(*p++);
41 if (*p == '\\')
42 putchar(*p);
43 }
44 putchar(*p);
45 }
46 }
47 }
48}