ReactOS 0.4.17-dev-218-g5635d24
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 934 of file mlang.c.

941{
942 INT src_len = -1;
943
944 TRACE("%p %ld %s %p %p %p\n", pdwMode, dwEncoding,
945 debugstr_a(pSrcStr), pcSrcSize, pDstStr, pcDstSize);
946
947 if (!pcDstSize)
948 return E_FAIL;
949
950 if (!pcSrcSize)
951 pcSrcSize = &src_len;
952
953 if (!*pcSrcSize)
954 {
955 *pcDstSize = 0;
956 return S_OK;
957 }
958
959 /* forwarding euc-jp to EUC-JP */
960 if (dwEncoding == 51932)
961 dwEncoding = 20932;
962
963 switch (dwEncoding)
964 {
965 case CP_UNICODE:
966 if (*pcSrcSize == -1)
967 *pcSrcSize = lstrlenW((LPCWSTR)pSrcStr);
968 *pcDstSize = min(*pcSrcSize, *pcDstSize);
969 *pcSrcSize *= sizeof(WCHAR);
970 if (pDstStr)
971 memmove(pDstStr, pSrcStr, *pcDstSize * sizeof(WCHAR));
972 break;
973
974 case 50220:
975 case 50221:
976 case 50222:
977 *pcDstSize = ConvertJISJapaneseToUnicode(pSrcStr,*pcSrcSize,pDstStr,*pcDstSize);
978 break;
979 case 50932:
980 *pcDstSize = ConvertUnknownJapaneseToUnicode(pSrcStr,*pcSrcSize,pDstStr,*pcDstSize);
981 break;
982
983 default:
984 if (*pcSrcSize == -1)
985 *pcSrcSize = lstrlenA(pSrcStr);
986
987 if (pDstStr)
988 *pcDstSize = MultiByteToWideChar(dwEncoding, 0, pSrcStr, *pcSrcSize, pDstStr, *pcDstSize);
989 else
990 *pcDstSize = MultiByteToWideChar(dwEncoding, 0, pSrcStr, *pcSrcSize, NULL, 0);
991 break;
992 }
993
994 if (!*pcDstSize)
995 return E_FAIL;
996
997 return S_OK;
998}
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
#define MultiByteToWideChar
Definition: compat.h:110
#define lstrlenW
Definition: compat.h:750
static UINT ConvertUnknownJapaneseToUnicode(LPCSTR input, DWORD count, LPWSTR output, DWORD out_count)
Definition: mlang.c:851
static UINT ConvertJISJapaneseToUnicode(LPCSTR input, DWORD count, LPWSTR output, DWORD out_count)
Definition: mlang.c:831
#define CP_UNICODE
Definition: stg_prop.c:73
#define S_OK
Definition: intsafe.h:52
#define debugstr_a
Definition: kernel32.h:31
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define min(a, b)
Definition: monoChain.cc:55
short WCHAR
Definition: pedump.c:58
#define TRACE(s)
Definition: solgame.cpp:4
const uint16_t * LPCWSTR
Definition: typedefs.h:57
int32_t INT
Definition: typedefs.h:58

◆ 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 1000 of file mlang.c.

1007{
1008 INT destsz, size;
1009 INT src_len = -1;
1010
1011 TRACE("%p %ld %s %p %p %p\n", pdwMode, dwEncoding,
1012 debugstr_w(pSrcStr), pcSrcSize, pDstStr, pcDstSize);
1013
1014 if (!pcDstSize)
1015 return S_OK;
1016
1017 if (!pcSrcSize)
1018 pcSrcSize = &src_len;
1019
1020 destsz = (pDstStr) ? *pcDstSize : 0;
1021 *pcDstSize = 0;
1022
1023 if (!pSrcStr || !*pcSrcSize)
1024 return S_OK;
1025
1026 if (*pcSrcSize == -1)
1027 *pcSrcSize = lstrlenW(pSrcStr);
1028
1029 /* forwarding euc-jp to EUC-JP */
1030 if (dwEncoding == 51932)
1031 dwEncoding = 20932;
1032
1033 if (dwEncoding == CP_UNICODE)
1034 {
1035 if (*pcSrcSize == -1)
1036 *pcSrcSize = lstrlenW(pSrcStr);
1037
1038 size = min(*pcSrcSize, destsz) * sizeof(WCHAR);
1039 if (pDstStr)
1040 memmove(pDstStr, pSrcStr, size);
1041
1042 if (size >= destsz)
1043 goto fail;
1044 }
1045 else if (dwEncoding == 50220 || dwEncoding == 50221 || dwEncoding == 50222)
1046 {
1047 size = ConvertJapaneseUnicodeToJIS(pSrcStr, *pcSrcSize, NULL, 0);
1048 if (!size)
1049 goto fail;
1050
1051 if (pDstStr)
1052 {
1053 size = ConvertJapaneseUnicodeToJIS(pSrcStr, *pcSrcSize, pDstStr,
1054 destsz);
1055 if (!size)
1056 goto fail;
1057 }
1058
1059 }
1060 else
1061 {
1062 size = WideCharToMultiByte(dwEncoding, 0, pSrcStr, *pcSrcSize,
1063 NULL, 0, NULL, NULL);
1064 if (!size)
1065 goto fail;
1066
1067 if (pDstStr)
1068 {
1069 size = WideCharToMultiByte(dwEncoding, 0, pSrcStr, *pcSrcSize,
1070 pDstStr, destsz, NULL, NULL);
1071 if (!size)
1072 goto fail;
1073 }
1074 }
1075
1076 *pcDstSize = size;
1077 return S_OK;
1078
1079fail:
1080 *pcSrcSize = 0;
1081 *pcDstSize = 0;
1082 return E_FAIL;
1083}
#define WideCharToMultiByte
Definition: compat.h:111
static UINT ConvertJapaneseUnicodeToJIS(LPCWSTR input, DWORD count, LPSTR output, DWORD out_count)
Definition: mlang.c:899
GLsizeiptr size
Definition: glext.h:5919
#define debugstr_w
Definition: kernel32.h:32

◆ IsConvertINetStringAvailable()

HRESULT WINAPI IsConvertINetStringAvailable ( DWORD  dwSrcEncoding,
DWORD  dwDstEncoding 
)

Definition at line 1161 of file mlang.c.

1164{
1165 UINT src_family, dst_family;
1166
1167 TRACE("%ld %ld\n", dwSrcEncoding, dwDstEncoding);
1168
1169 if (GetFamilyCodePage(dwSrcEncoding, &src_family) != S_OK ||
1170 GetFamilyCodePage(dwDstEncoding, &dst_family) != S_OK)
1171 return S_FALSE;
1172
1173 if (src_family == dst_family) return S_OK;
1174
1175 /* we can convert any codepage to/from unicode */
1176 if (src_family == CP_UNICODE || dst_family == CP_UNICODE) return S_OK;
1177
1178 return S_FALSE;
1179}
static HRESULT GetFamilyCodePage(UINT uiCodePage, UINT *puiFamilyCodePage)
Definition: mlang.c:1136
unsigned int UINT
Definition: ndis.h:50
#define S_FALSE
Definition: winerror.h:3451

◆ 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 
)