diff options
| author | Ron Yorston <rmy@pobox.com> | 2023-06-23 07:33:48 +0100 |
|---|---|---|
| committer | Ron Yorston <rmy@pobox.com> | 2023-06-23 07:33:48 +0100 |
| commit | 1dda33d8c7da2a8a6ab2ed2805fc9bd50c1a0a4f (patch) | |
| tree | 5c04fdc3c8a16be7b2df11b43d665635c37453c6 | |
| parent | 597d31eefb4a41abcf2d3c300c2b910b11a9f98c (diff) | |
| download | busybox-w32-1dda33d8c7da2a8a6ab2ed2805fc9bd50c1a0a4f.tar.gz busybox-w32-1dda33d8c7da2a8a6ab2ed2805fc9bd50c1a0a4f.tar.bz2 busybox-w32-1dda33d8c7da2a8a6ab2ed2805fc9bd50c1a0a4f.zip | |
win32: reduce impact of euro support
The workaround for euro support in busybox-w32 is only intended
to work in the 858 code page. Skip the workaround if any other
code page is in use.
Costs 8-36 bytes.
(GitHub issue #335)
| -rw-r--r-- | win32/winansi.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/win32/winansi.c b/win32/winansi.c index 84652b5f2..45bb8806c 100644 --- a/win32/winansi.c +++ b/win32/winansi.c | |||
| @@ -725,6 +725,9 @@ static BOOL winansi_CharToOemBuff(LPCSTR s, LPSTR d, DWORD len) | |||
| 725 | WCHAR *buf; | 725 | WCHAR *buf; |
| 726 | int i; | 726 | int i; |
| 727 | 727 | ||
| 728 | if (GetConsoleOutputCP() != 858) | ||
| 729 | return CharToOemBuff(s, d, len); | ||
| 730 | |||
| 728 | if (!s || !d) | 731 | if (!s || !d) |
| 729 | return FALSE; | 732 | return FALSE; |
| 730 | 733 | ||
| @@ -732,11 +735,9 @@ static BOOL winansi_CharToOemBuff(LPCSTR s, LPSTR d, DWORD len) | |||
| 732 | buf = xmalloc(len*sizeof(WCHAR)); | 735 | buf = xmalloc(len*sizeof(WCHAR)); |
| 733 | MultiByteToWideChar(CP_ACP, 0, s, len, buf, len); | 736 | MultiByteToWideChar(CP_ACP, 0, s, len, buf, len); |
| 734 | WideCharToMultiByte(CP_OEMCP, 0, buf, len, d, len, NULL, NULL); | 737 | WideCharToMultiByte(CP_OEMCP, 0, buf, len, d, len, NULL, NULL); |
| 735 | if (GetConsoleOutputCP() == 858) { | 738 | for (i=0; i<len; ++i) { |
| 736 | for (i=0; i<len; ++i) { | 739 | if (buf[i] == 0x20ac) { |
| 737 | if (buf[i] == 0x20ac) { | 740 | d[i] = 0xd5; |
| 738 | d[i] = 0xd5; | ||
| 739 | } | ||
| 740 | } | 741 | } |
| 741 | } | 742 | } |
| 742 | free(buf); | 743 | free(buf); |
| @@ -755,6 +756,9 @@ BOOL winansi_OemToCharBuff(LPCSTR s, LPSTR d, DWORD len) | |||
| 755 | WCHAR *buf; | 756 | WCHAR *buf; |
| 756 | int i; | 757 | int i; |
| 757 | 758 | ||
| 759 | if (GetConsoleCP() != 858) | ||
| 760 | return OemToCharBuff(s, d, len); | ||
| 761 | |||
| 758 | if (!s || !d) | 762 | if (!s || !d) |
| 759 | return FALSE; | 763 | return FALSE; |
| 760 | 764 | ||
| @@ -762,11 +766,9 @@ BOOL winansi_OemToCharBuff(LPCSTR s, LPSTR d, DWORD len) | |||
| 762 | buf = xmalloc(len*sizeof(WCHAR)); | 766 | buf = xmalloc(len*sizeof(WCHAR)); |
| 763 | MultiByteToWideChar(CP_OEMCP, 0, s, len, buf, len); | 767 | MultiByteToWideChar(CP_OEMCP, 0, s, len, buf, len); |
| 764 | WideCharToMultiByte(CP_ACP, 0, buf, len, d, len, NULL, NULL); | 768 | WideCharToMultiByte(CP_ACP, 0, buf, len, d, len, NULL, NULL); |
| 765 | if (GetConsoleOutputCP() == 858) { | 769 | for (i=0; i<len; ++i) { |
| 766 | for (i=0; i<len; ++i) { | 770 | if (buf[i] == 0x0131) { |
| 767 | if (buf[i] == 0x0131) { | 771 | d[i] = 0x80; |
| 768 | d[i] = 0x80; | ||
| 769 | } | ||
| 770 | } | 772 | } |
| 771 | } | 773 | } |
| 772 | free(buf); | 774 | free(buf); |
