readline.c: fix 8b2e925c
This commit is contained in:
		
							parent
							
								
									2c9b79a6af
								
							
						
					
					
						commit
						00323b1942
					
				
							
								
								
									
										16
									
								
								src/osdep.c
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								src/osdep.c
									
									
									
									
									
								
							@ -311,6 +311,22 @@ char * Unicode_to_utf8(const word * str, size_t * utf8len)
 | 
			
		||||
    return utf8;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * UTF8 to Unicode (16bits per character).
 | 
			
		||||
 * use MultiByteToWideChar(CP_UTF8, ...) under WIN32.
 | 
			
		||||
 * Note :  For UTF-8, dwFlags must be set to either 0 or MB_ERR_INVALID_CHARS.
 | 
			
		||||
 */
 | 
			
		||||
void Unicode_from_utf8(const char * utf8, word * unicode, size_t unicodelen)
 | 
			
		||||
{
 | 
			
		||||
  int r = MultiByteToWideChar(CP_UTF8, 0, utf8, -1, (LPWSTR)unicode, unicodelen);
 | 
			
		||||
  if (r == 0)
 | 
			
		||||
  {
 | 
			
		||||
    GFX2_Log(GFX2_ERROR, "MultiByteToWideChar(CP_UTF8, \"%s\", ...) failed with error #%u\n", utf8, GetLastError());
 | 
			
		||||
    unicode[0] = 0;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 | 
			
		||||
@ -56,6 +56,7 @@ unsigned long Memory_free(void);
 | 
			
		||||
 | 
			
		||||
#if defined(WIN32)
 | 
			
		||||
char * Unicode_to_utf8(const word * str, size_t * utf8len);
 | 
			
		||||
void Unicode_from_utf8(const char * utf8, word * unicode, size_t unicodelen);
 | 
			
		||||
 | 
			
		||||
void GFX2_GetShortPathName(char * shortname, size_t shortname_len, const word * longname);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
@ -709,15 +709,7 @@ byte Readline_ex_unicode(word x_pos, word y_pos, char * str, word * str_unicode,
 | 
			
		||||
        unicode_text[0] = 0;
 | 
			
		||||
      }
 | 
			
		||||
#elif defined(WIN32)
 | 
			
		||||
      // use MultiByteToWideChar(CP_UTF8, ...) under WIN32
 | 
			
		||||
      // Note :  For UTF-8, dwFlags must be set to either 0 or
 | 
			
		||||
      // MB_ERR_INVALID_CHARS.
 | 
			
		||||
      i = MultiByteToWideChar(CP_UTF8, 0, Key_Text, -1, (LPWSTR)unicode_text, sizeof(unicode_text)/sizeof(word));
 | 
			
		||||
      if (i == 0)
 | 
			
		||||
      {
 | 
			
		||||
        GFX2_Log(GFX2_ERROR, "MultiByteToWideChar(CP_UTF8, \"%s\", ...) failed with error #%u\n", Key_Text, GetLastError());
 | 
			
		||||
        unicode_text[0] = 0;
 | 
			
		||||
      }
 | 
			
		||||
      Unicode_from_utf8(Key_Text, unicode_text, sizeof(unicode_text)/sizeof(word));
 | 
			
		||||
#else
 | 
			
		||||
      int j;
 | 
			
		||||
      for (i = 0, j = 0; i < (int)sizeof(Key_Text) && j < (int)sizeof(unicode_text) && Key_Text[i] != '\0'; i++)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user