blob: fec4740c045ffe59b95daa732dec1058a40f6b0d [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
10main(argc, argv)
11 int argc;
12 char **argv;
13{
14 char buffer[BUFSIZ];
15 char *p;
16
17 while (fgets(buffer, BUFSIZ, stdin) != NULL)
18 {
19 for (p = buffer; *p != 0; p++)
20 {
Bram Moolenaare6ae6222013-05-21 21:01:10 +020021 if (strncmp(p, "charset=utf-8", 13) == 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +000022 {
23 fputs("charset=cp932", stdout);
Bram Moolenaare6ae6222013-05-21 21:01:10 +020024 p += 12;
Bram Moolenaar071d4272004-06-13 20:20:40 +000025 }
26 else if (strncmp(p, "ja.po - Japanese message file", 29) == 0)
27 {
28 fputs("ja.sjis.po - Japanese message file for Vim (version 6.x)\n", stdout);
29 fputs("# generated from ja.po, DO NOT EDIT", stdout);
30 while (p[1] != '\n')
31 ++p;
32 }
33 else if (*(unsigned char *)p == 0x81 && p[1] == '_')
34 {
35 putchar('\\');
36 ++p;
37 }
38 else
39 {
40 if (*p & 0x80)
41 {
42 putchar(*p++);
43 if (*p == '\\')
44 putchar(*p);
45 }
46 putchar(*p);
47 }
48 }
49 }
50}