ReactOS  0.4.14-dev-342-gdc047f9
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 952 of file mlang.c.

959 {
960  INT src_len = -1;
961 
962  TRACE("%p %d %s %p %p %p\n", pdwMode, dwEncoding,
963  debugstr_a(pSrcStr), pcSrcSize, pDstStr, pcDstSize);
964 
965  if (!pcDstSize)
966  return E_FAIL;
967 
968  if (!pcSrcSize)
969  pcSrcSize = &src_len;
970 
971  if (!*pcSrcSize)
972  {
973  *pcDstSize = 0;
974  return S_OK;
975  }
976 
977  /* forwarding euc-jp to EUC-JP */
978  if (dwEncoding == 51932)
979  dwEncoding = 20932;
980 
981  switch (dwEncoding)
982  {
983  case CP_UNICODE:
984  if (*pcSrcSize == -1)
985  *pcSrcSize = lstrlenW((LPCWSTR)pSrcStr);
986  *pcDstSize = min(*pcSrcSize, *pcDstSize);
987  *pcSrcSize *= sizeof(WCHAR);
988  if (pDstStr)
989  memmove(pDstStr, pSrcStr, *pcDstSize * sizeof(WCHAR));
990  break;
991 
992  case 50220:
993  case 50221:
994  case 50222:
995  *pcDstSize = ConvertJISJapaneseToUnicode(pSrcStr,*pcSrcSize,pDstStr,*pcDstSize);
996  break;
997  case 50932:
998  *pcDstSize = ConvertUnknownJapaneseToUnicode(pSrcStr,*pcSrcSize,pDstStr,*pcDstSize);
999  break;
1000 
1001  default:
1002  if (*pcSrcSize == -1)
1003  *pcSrcSize = lstrlenA(pSrcStr);
1004 
1005  if (pDstStr)
1006  *pcDstSize = MultiByteToWideChar(dwEncoding, 0, pSrcStr, *pcSrcSize, pDstStr, *pcDstSize);
1007  else
1008  *pcDstSize = MultiByteToWideChar(dwEncoding, 0, pSrcStr, *pcSrcSize, NULL, 0);
1009  break;
1010  }
1011 
1012  if (!*pcDstSize)
1013  return E_FAIL;
1014 
1015  return S_OK;
1016 }
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define lstrlenW
Definition: compat.h:415
#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:853
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:833
#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 1018 of file mlang.c.

1025 {
1026  INT destsz, size;
1027  INT src_len = -1;
1028 
1029  TRACE("%p %d %s %p %p %p\n", pdwMode, dwEncoding,
1030  debugstr_w(pSrcStr), pcSrcSize, pDstStr, pcDstSize);
1031 
1032  if (!pcDstSize)
1033  return S_OK;
1034 
1035  if (!pcSrcSize)
1036  pcSrcSize = &src_len;
1037 
1038  destsz = (pDstStr) ? *pcDstSize : 0;
1039  *pcDstSize = 0;
1040 
1041  if (!pSrcStr || !*pcSrcSize)
1042  return S_OK;
1043 
1044  if (*pcSrcSize == -1)
1045  *pcSrcSize = lstrlenW(pSrcStr);
1046 
1047  /* forwarding euc-jp to EUC-JP */
1048  if (dwEncoding == 51932)
1049  dwEncoding = 20932;
1050 
1051  if (dwEncoding == CP_UNICODE)
1052  {
1053  if (*pcSrcSize == -1)
1054  *pcSrcSize = lstrlenW(pSrcStr);
1055 
1056  size = min(*pcSrcSize, destsz) * sizeof(WCHAR);
1057  if (pDstStr)
1058  memmove(pDstStr, pSrcStr, size);
1059 
1060  if (size >= destsz)
1061  goto fail;
1062  }
1063  else if (dwEncoding == 50220 || dwEncoding == 50221 || dwEncoding == 50222)
1064  {
1065  size = ConvertJapaneseUnicodeToJIS(pSrcStr, *pcSrcSize, NULL, 0);
1066  if (!size)
1067  goto fail;
1068 
1069  if (pDstStr)
1070  {
1071  size = ConvertJapaneseUnicodeToJIS(pSrcStr, *pcSrcSize, pDstStr,
1072  destsz);
1073  if (!size)
1074  goto fail;
1075  }
1076 
1077  }
1078  else
1079  {
1080  size = WideCharToMultiByte(dwEncoding, 0, pSrcStr, *pcSrcSize,
1081  NULL, 0, NULL, NULL);
1082  if (!size)
1083  goto fail;
1084 
1085  if (pDstStr)
1086  {
1087  size = WideCharToMultiByte(dwEncoding, 0, pSrcStr, *pcSrcSize,
1088  pDstStr, destsz, NULL, NULL);
1089  if (!size)
1090  goto fail;
1091  }
1092  }
1093 
1094  *pcDstSize = size;
1095  return S_OK;
1096 
1097 fail:
1098  *pcSrcSize = 0;
1099  *pcDstSize = 0;
1100  return E_FAIL;
1101 }
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
static UINT ConvertJapaneseUnicodeToJIS(LPCWSTR input, DWORD count, LPSTR output, DWORD out_count)
Definition: mlang.c:901
#define WideCharToMultiByte
Definition: compat.h:101
#define lstrlenW
Definition: compat.h:415
#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 1179 of file mlang.c.

1182 {
1183  UINT src_family, dst_family;
1184 
1185  TRACE("%d %d\n", dwSrcEncoding, dwDstEncoding);
1186 
1187  if (GetFamilyCodePage(dwSrcEncoding, &src_family) != S_OK ||
1188  GetFamilyCodePage(dwDstEncoding, &dst_family) != S_OK)
1189  return S_FALSE;
1190 
1191  if (src_family == dst_family) return S_OK;
1192 
1193  /* we can convert any codepage to/from unicode */
1194  if (src_family == CP_UNICODE || dst_family == CP_UNICODE) return S_OK;
1195 
1196  return S_FALSE;
1197 }
#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:1154

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 
)