Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | When translating UTF8 text for display on the console, use the codepage obtained from GetConsoleCP(), not the CP_ACP code page that is used for system calls. |
|---|---|
| Timelines: | family | ancestors | descendants | both | windows-i18n |
| Files: | files | file ages | folders |
| SHA1: |
55b32701a573b63509701aab405c2d42 |
| User & Date: | drh 2011-05-13 15:46:10.422 |
Context
|
2011-05-13
| ||
| 17:13 | Ignore short writes when writing to the console. check-in: e7babf5222 user: drh tags: windows-i18n | |
| 15:46 | When translating UTF8 text for display on the console, use the codepage obtained from GetConsoleCP(), not the CP_ACP code page that is used for system calls. check-in: 55b32701a5 user: drh tags: windows-i18n | |
| 14:20 | Pull the latest changes in trunk over into the windows-i18n branch. check-in: 70743ebae5 user: drh tags: windows-i18n | |
Changes
Changes to src/file.c.
| ︙ | ︙ | |||
693 694 695 696 697 698 699 700 701 | /************************************************************************** ** The following routines translate between MBCS and UTF8 on windows. ** Since everything is always UTF8 on unix, these routines are no-ops ** there. */ /* | > > > | | > | > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 |
/**************************************************************************
** The following routines translate between MBCS and UTF8 on windows.
** Since everything is always UTF8 on unix, these routines are no-ops
** there.
*/
#ifdef _WIN32
# include <windows.h>
#endif
/*
** Translate MBCS to UTF8. Return a pointer to the translated text.
** Call fossil_mbcs_free() to deallocate any memory used to store the
** returned pointer when done.
*/
char *fossil_mbcs_to_utf8(const char *zMbcs){
#ifdef _WIN32
extern char *sqlite3_win32_mbcs_to_utf8(const char*);
return sqlite3_win32_mbcs_to_utf8(zMbcs);
#else
return (char*)zMbcs; /* No-op on unix */
#endif
}
/*
** Translate UTF8 to MBCS for use in system calls. Return a pointer to the
** translated text.. Call fossil_mbcs_free() to deallocate any memory
** used to store the returned pointer when done.
*/
char *fossil_utf8_to_mbcs(const char *zUtf8){
#ifdef _WIN32
extern char *sqlite3_win32_utf8_to_mbcs(const char*);
return sqlite3_win32_utf8_to_mbcs(zUtf8);
#else
return (char*)zUtf8; /* No-op on unix */
#endif
}
/*
** Translate UTF8 to MBCS for display on the console. Return a pointer to the
** translated text.. Call fossil_mbcs_free() to deallocate any memory
** used to store the returned pointer when done.
*/
char *fossil_utf8_to_console(const char *zUtf8){
#ifdef _WIN32
int nChar, nByte;
WCHAR *zUnicode; /* Unicode version of zUtf8 */
char *zConsole; /* Console version of zUtf8 */
int codepage; /* Console code page */
nChar = MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, NULL, 0);
zUnicode = malloc( nChar*sizeof(zUnicode[0]) );
if( zUnicode==0 ){
return 0;
}
nChar = MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, zUnicode, nChar);
if( nChar==0 ){
free(zUnicode);
return 0;
}
codepage = GetConsoleCP();
nByte = WideCharToMultiByte(codepage, 0, zUnicode, -1, 0, 0, 0, 0);
zConsole = malloc( nByte );
if( zConsole==0 ){
free(zUnicode);
return 0;
}
nByte = WideCharToMultiByte(codepage, 0, zUnicode, -1, zConsole, nByte, 0, 0);
free(zUnicode);
if( nByte == 0 ){
free(zConsole);
zConsole = 0;
}
return zConsole;
#else
return (char*)zUtf8; /* No-op on unix */
#endif
}
/*
** Translate MBCS to UTF8. Return a pointer. Call fossil_mbcs_free()
|
| ︙ | ︙ |
Changes to src/printf.c.
| ︙ | ︙ | |||
805 806 807 808 809 810 811 |
**
** On windows, transform the output into the current terminal encoding
** if the output is going to the screen. If output is redirected into
** a file, no translation occurs. No translation ever occurs on unix.
*/
void fossil_puts(const char *z, int toStdErr){
#if defined(_WIN32)
| < | | 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 |
**
** On windows, transform the output into the current terminal encoding
** if the output is going to the screen. If output is redirected into
** a file, no translation occurs. No translation ever occurs on unix.
*/
void fossil_puts(const char *z, int toStdErr){
#if defined(_WIN32)
static int once = 1;
static int istty[2];
char *zToFree = 0;
if( once ){
istty[0] = _isatty(fileno(stdout));
istty[1] = _isatty(fileno(stderr));
once = 0;
}
assert( toStdErr==0 || toStdErr==1 );
if( istty[toStdErr] ) z = zToFree = fossil_utf8_to_console(z);
fwrite(z, 1, strlen(z), toStdErr ? stderr : stdout);
free(zToFree);
#else
fwrite(z, 1, strlen(z), toStdErr ? stderr : stdout);
#endif
}
|
| ︙ | ︙ |