ReactOS  0.4.13-dev-563-g0561610
mlang.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

HRESULT WINAPI ConvertINetString (LPDWORD lpdwMode, DWORD dwSrcEncoding, DWORD dwDstEncoding, LPCSTR lpSrcStr, LPINT lpnSrcSize, LPBYTE lpDstStr, LPINT lpnDstSize)
 
HRESULT WINAPI ConvertINetMultiByteToUnicode (LPDWORD lpdwMode, DWORD dwSrcEncoding, LPCSTR lpSrcStr, LPINT lpnMultiCharCount, LPWSTR lpDstStr, LPINT lpnWideCharCount)
 
HRESULT WINAPI ConvertINetUnicodeToMultiByte (LPDWORD lpdwMode, DWORD dwEncoding, LPCWSTR lpSrcStr, LPINT lpnWideCharCount, LPSTR lpDstStr, LPINT lpnMultiCharCount)
 
HRESULT WINAPI IsConvertINetStringAvailable (DWORD dwSrcEncoding, DWORD dwDstEncoding)
 
HRESULT WINAPI LcidToRfc1766A (LCID Locale, LPSTR pszRfc1766, int nChar)
 
HRESULT WINAPI LcidToRfc1766W (LCID Locale, LPWSTR pszRfc1766, int nChar)
 
HRESULT WINAPI Rfc1766ToLcidA (LCID *pLocale, LPSTR pszRfc1766)
 
HRESULT WINAPI Rfc1766ToLcidW (LCID *pLocale, LPWSTR pszRfc1766)
 

Function Documentation

◆ ConvertINetMultiByteToUnicode()

HRESULT WINAPI ConvertINetMultiByteToUnicode ( LPDWORD  lpdwMode,
DWORD  dwSrcEncoding,
LPCSTR  lpSrcStr,
LPINT  lpnMultiCharCount,
LPWSTR  lpDstStr,
LPINT  lpnWideCharCount 
)

Definition at line 954 of file mlang.c.

961 {
962  INT src_len = -1;
963 
964  TRACE("%p %d %s %p %p %p\n", pdwMode, dwEncoding,
965  debugstr_a(pSrcStr), pcSrcSize, pDstStr, pcDstSize);
966 
967  if (!pcDstSize)
968  return E_FAIL;
969 
970  if (!pcSrcSize)
971  pcSrcSize = &src_len;
972 
973  if (!*pcSrcSize)
974  {
975  *pcDstSize = 0;
976  return S_OK;
977  }
978 
979  /* forwarding euc-jp to EUC-JP */
980  if (dwEncoding == 51932)
981  dwEncoding = 20932;
982 
983  switch (dwEncoding)
984  {
985  case CP_UNICODE:
986  if (*pcSrcSize == -1)
987  *pcSrcSize = lstrlenW((LPCWSTR)pSrcStr);
988  *pcDstSize = min(*pcSrcSize, *pcDstSize);
989  *pcSrcSize *= sizeof(WCHAR);
990  if (pDstStr)
991  memmove(pDstStr, pSrcStr, *pcDstSize * sizeof(WCHAR));
992  break;
993 
994  case 50220:
995  case 50221:
996  case 50222:
997  *pcDstSize = ConvertJISJapaneseToUnicode(pSrcStr,*pcSrcSize,pDstStr,*pcDstSize);
998  break;
999  case 50932:
1000  *pcDstSize = ConvertUnknownJapaneseToUnicode(pSrcStr,*pcSrcSize,pDstStr,*pcDstSize);
1001  break;
1002 
1003  default:
1004  if (*pcSrcSize == -1)
1005  *pcSrcSize = lstrlenA(pSrcStr);
1006 
1007  if (pDstStr)
1008  *pcDstSize = MultiByteToWideChar(dwEncoding, 0, pSrcStr, *pcSrcSize, pDstStr, *pcDstSize);
1009  else
1010  *pcDstSize = MultiByteToWideChar(dwEncoding, 0, pSrcStr, *pcSrcSize, NULL, 0);
1011  break;
1012  }
1013 
1014  if (!*pcDstSize)
1015  return E_FAIL;
1016 
1017  return S_OK;
1018 }
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define lstrlenW
Definition: compat.h:407
#define E_FAIL
Definition: ddrawi.h:102
int32_t INT
Definition: typedefs.h:56
static UINT ConvertUnknownJapaneseToUnicode(LPCSTR input, DWORD count, LPWSTR output, DWORD out_count)
Definition: mlang.c:855
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define CP_UNICODE
Definition: mlang.c:39
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
#define S_OK
Definition: intsafe.h:59
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
static UINT ConvertJISJapaneseToUnicode(LPCSTR input, DWORD count, LPWSTR output, DWORD out_count)
Definition: mlang.c:835
#define min(a, b)
Definition: monoChain.cc:55
#define MultiByteToWideChar
Definition: compat.h:100

Referenced by ConvertINetString(), fnIMultiLanguage3_ConvertStringToUnicode(), fnIMultiLanguage3_ConvertStringToUnicodeEx(), and MLangConvertCharset_DoConversionToUnicode().

◆ ConvertINetString()

HRESULT WINAPI ConvertINetString ( LPDWORD  lpdwMode,
DWORD  dwSrcEncoding,
DWORD  dwDstEncoding,
LPCSTR  lpSrcStr,
LPINT  lpnSrcSize,
LPBYTE  lpDstStr,
LPINT  lpnDstSize 
)

◆ ConvertINetUnicodeToMultiByte()

HRESULT WINAPI ConvertINetUnicodeToMultiByte ( LPDWORD  lpdwMode,
DWORD  dwEncoding,
LPCWSTR  lpSrcStr,
LPINT  lpnWideCharCount,
LPSTR  lpDstStr,
LPINT  lpnMultiCharCount 
)

Definition at line 1020 of file mlang.c.

1027 {
1028  INT destsz, size;
1029  INT src_len = -1;
1030 
1031  TRACE("%p %d %s %p %p %p\n", pdwMode, dwEncoding,
1032  debugstr_w(pSrcStr), pcSrcSize, pDstStr, pcDstSize);
1033 
1034  if (!pcDstSize)
1035  return S_OK;
1036 
1037  if (!pcSrcSize)
1038  pcSrcSize = &src_len;
1039 
1040  destsz = (pDstStr) ? *pcDstSize : 0;
1041  *pcDstSize = 0;
1042 
1043  if (!pSrcStr || !*pcSrcSize)
1044  return S_OK;
1045 
1046  if (*pcSrcSize == -1)
1047  *pcSrcSize = lstrlenW(pSrcStr);
1048 
1049  /* forwarding euc-jp to EUC-JP */
1050  if (dwEncoding == 51932)
1051  dwEncoding = 20932;
1052 
1053  if (dwEncoding == CP_UNICODE)
1054  {
1055  if (*pcSrcSize == -1)
1056  *pcSrcSize = lstrlenW(pSrcStr);
1057 
1058  size = min(*pcSrcSize, destsz) * sizeof(WCHAR);
1059  if (pDstStr)
1060  memmove(pDstStr, pSrcStr, size);
1061 
1062  if (size >= destsz)
1063  goto fail;
1064  }
1065  else if (dwEncoding == 50220 || dwEncoding == 50221 || dwEncoding == 50222)
1066  {
1067  size = ConvertJapaneseUnicodeToJIS(pSrcStr, *pcSrcSize, NULL, 0);
1068  if (!size)
1069  goto fail;
1070 
1071  if (pDstStr)
1072  {
1073  size = ConvertJapaneseUnicodeToJIS(pSrcStr, *pcSrcSize, pDstStr,
1074  destsz);
1075  if (!size)
1076  goto fail;
1077  }
1078 
1079  }
1080  else
1081  {
1082  size = WideCharToMultiByte(dwEncoding, 0, pSrcStr, *pcSrcSize,
1083  NULL, 0, NULL, NULL);
1084  if (!size)
1085  goto fail;
1086 
1087  if (pDstStr)
1088  {
1089  size = WideCharToMultiByte(dwEncoding, 0, pSrcStr, *pcSrcSize,
1090  pDstStr, destsz, NULL, NULL);
1091  if (!size)
1092  goto fail;
1093  }
1094  }
1095 
1096  *pcDstSize = size;
1097  return S_OK;
1098 
1099 fail:
1100  *pcSrcSize = 0;
1101  *pcDstSize = 0;
1102  return E_FAIL;
1103 }
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
static UINT ConvertJapaneseUnicodeToJIS(LPCWSTR input, DWORD count, LPSTR output, DWORD out_count)
Definition: mlang.c:903
#define WideCharToMultiByte
Definition: compat.h:101
#define lstrlenW
Definition: compat.h:407
#define E_FAIL
Definition: ddrawi.h:102
int32_t INT
Definition: typedefs.h:56
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define CP_UNICODE
Definition: mlang.c:39
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define S_OK
Definition: intsafe.h:59
#define min(a, b)
Definition: monoChain.cc:55

Referenced by ConvertINetString(), fnIMultiLanguage3_ConvertStringFromUnicode(), fnIMultiLanguage3_ConvertStringFromUnicodeEx(), and MLangConvertCharset_DoConversionFromUnicode().

◆ IsConvertINetStringAvailable()

HRESULT WINAPI IsConvertINetStringAvailable ( DWORD  dwSrcEncoding,
DWORD  dwDstEncoding 
)

Definition at line 1181 of file mlang.c.

1184 {
1185  UINT src_family, dst_family;
1186 
1187  TRACE("%d %d\n", dwSrcEncoding, dwDstEncoding);
1188 
1189  if (GetFamilyCodePage(dwSrcEncoding, &src_family) != S_OK ||
1190  GetFamilyCodePage(dwDstEncoding, &dst_family) != S_OK)
1191  return S_FALSE;
1192 
1193  if (src_family == dst_family) return S_OK;
1194 
1195  /* we can convert any codepage to/from unicode */
1196  if (src_family == CP_UNICODE || dst_family == CP_UNICODE) return S_OK;
1197 
1198  return S_FALSE;
1199 }
#define S_FALSE
Definition: winerror.h:2357
#define TRACE(s)
Definition: solgame.cpp:4
#define CP_UNICODE
Definition: mlang.c:39
#define S_OK
Definition: intsafe.h:59
unsigned int UINT
Definition: ndis.h:50
static HRESULT GetFamilyCodePage(UINT uiCodePage, UINT *puiFamilyCodePage)
Definition: mlang.c:1156

Referenced by fnIMultiLanguage3_IsConvertible().

◆ LcidToRfc1766A()

HRESULT WINAPI LcidToRfc1766A ( LCID  Locale,
LPSTR  pszRfc1766,
int  nChar 
)

◆ LcidToRfc1766W()

HRESULT WINAPI LcidToRfc1766W ( LCID  Locale,
LPWSTR  pszRfc1766,
int  nChar 
)

◆ Rfc1766ToLcidA()

HRESULT WINAPI Rfc1766ToLcidA ( LCID pLocale,
LPSTR  pszRfc1766 
)

◆ Rfc1766ToLcidW()

HRESULT WINAPI Rfc1766ToLcidW ( LCID pLocale,
LPWSTR  pszRfc1766 
)