ReactOS 0.4.17-dev-117-g313be0c
mlang.idl File Reference

Go to the source code of this file.

Classes

interface  MultiLanguage::IMLangCodePages
 
interface  MultiLanguage::IMLangFontLink
 
interface  MultiLanguage::IEnumScript
 
struct  MultiLanguage::IEnumScript::tagSCRIPFONTINFO
 
struct  MultiLanguage::IEnumScript::tagSCRIPTINFO
 
interface  MultiLanguage::IMLangFontLink2
 
struct  MultiLanguage::IMLangFontLink2::tagUNICODERANGE
 
interface  MultiLanguage::IMLangString
 
interface  MultiLanguage::IMLangLineBreakConsole
 
interface  MultiLanguage::IEnumCodePage
 
struct  MultiLanguage::IEnumCodePage::tagMIMECPINFO
 
struct  MultiLanguage::IEnumCodePage::tagMIMECSETINFO
 
interface  MultiLanguage::IMLangConvertCharset
 
class  MultiLanguage::CMLangConvertCharset
 
interface  MultiLanguage::IEnumRfc1766
 
struct  MultiLanguage::IEnumRfc1766::tagRFC1766INFO
 
interface  MultiLanguage::IMultiLanguage
 
interface  MultiLanguage::IMultiLanguage2
 
struct  MultiLanguage::IMultiLanguage2::tagDetectEncodingInfo
 
interface  MultiLanguage::IMultiLanguage3
 
class  MultiLanguage::CMultiLanguage
 

Modules

library  MultiLanguage
 

Functions

 MultiLanguage::importlib ("stdole2.tlb")
 
STDAPI LcidToRfc1766A (LCID, LPSTR, INT)
 
STDAPI LcidToRfc1766W (LCID, LPWSTR, INT)
 
STDAPI Rfc1766ToLcidA (LCID *, LPCSTR)
 
STDAPI Rfc1766ToLcidW (LCID *, LPCWSTR)
 
STDAPI GetGlobalFontLinkObject (IMLangFontLink **obj)
 
STDAPI IsConvertINetStringAvailable (DWORD, DWORD)
 
STDAPI ConvertINetString (LPDWORD, DWORD, DWORD, LPCSTR, LPINT, LPSTR, LPINT)
 
STDAPI ConvertINetMultiByteToUnicode (LPDWORD, DWORD, LPCSTR, LPINT, LPWSTR, LPINT)
 
STDAPI ConvertINetUnicodeToMultiByte (LPDWORD, DWORD, LPCWSTR, LPINT, LPSTR, LPINT)
 

Function Documentation

◆ ConvertINetMultiByteToUnicode()

STDAPI ConvertINetMultiByteToUnicode ( LPDWORD  pdwMode,
DWORD  dwEncoding,
LPCSTR  pSrcStr,
LPINT  pcSrcSize,
LPWSTR  pDstStr,
LPINT  pcDstSize 
)

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

STDAPI ConvertINetString ( LPDWORD  pdwMode,
DWORD  dwSrcEncoding,
DWORD  dwDstEncoding,
LPCSTR  pSrcStr,
LPINT  pcSrcSize,
LPSTR  pDstStr,
LPINT  pcDstSize 
)

Definition at line 1085 of file mlang.c.

1094{
1095 TRACE("%p %ld %ld %s %p %p %p\n", pdwMode, dwSrcEncoding, dwDstEncoding,
1096 debugstr_a(pSrcStr), pcSrcSize, pDstStr, pcDstSize);
1097
1098 if (dwSrcEncoding == CP_UNICODE)
1099 {
1100 INT cSrcSizeW;
1101 if (pcSrcSize && *pcSrcSize != -1)
1102 {
1103 cSrcSizeW = *pcSrcSize / sizeof(WCHAR);
1104 pcSrcSize = &cSrcSizeW;
1105 }
1106 return ConvertINetUnicodeToMultiByte(pdwMode, dwDstEncoding, (LPCWSTR)pSrcStr, pcSrcSize, pDstStr, pcDstSize);
1107 }
1108 else if (dwDstEncoding == CP_UNICODE)
1109 {
1110 HRESULT hr = ConvertINetMultiByteToUnicode(pdwMode, dwSrcEncoding, pSrcStr, pcSrcSize, (LPWSTR)pDstStr, pcDstSize);
1111 *pcDstSize *= sizeof(WCHAR);
1112 return hr;
1113 }
1114 else
1115 {
1116 INT cDstSizeW;
1117 LPWSTR pDstStrW;
1118 HRESULT hr;
1119
1120 TRACE("convert %s from %ld to %ld\n", debugstr_a(pSrcStr), dwSrcEncoding, dwDstEncoding);
1121
1122 hr = ConvertINetMultiByteToUnicode(pdwMode, dwSrcEncoding, pSrcStr, pcSrcSize, NULL, &cDstSizeW);
1123 if (hr != S_OK)
1124 return hr;
1125
1126 pDstStrW = malloc(cDstSizeW * sizeof(WCHAR));
1127 hr = ConvertINetMultiByteToUnicode(pdwMode, dwSrcEncoding, pSrcStr, pcSrcSize, pDstStrW, &cDstSizeW);
1128 if (hr == S_OK)
1129 hr = ConvertINetUnicodeToMultiByte(pdwMode, dwDstEncoding, pDstStrW, &cDstSizeW, pDstStr, pcDstSize);
1130
1131 free(pDstStrW);
1132 return hr;
1133 }
1134}
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
HRESULT hr
Definition: delayimp.cpp:573
uint16_t * LPWSTR
Definition: typedefs.h:56
static CONVERTINETMULTIBYTETOUNICODE ConvertINetMultiByteToUnicode
Definition: win_iconv.c:705
static CONVERTINETUNICODETOMULTIBYTE ConvertINetUnicodeToMultiByte
Definition: win_iconv.c:706

◆ ConvertINetUnicodeToMultiByte()

STDAPI ConvertINetUnicodeToMultiByte ( LPDWORD  pdwMode,
DWORD  dwEncoding,
LPCWSTR  pSrcStr,
LPINT  pcSrcSize,
LPSTR  pDstStr,
LPINT  pcDstSize 
)

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

◆ GetGlobalFontLinkObject()

STDAPI GetGlobalFontLinkObject ( IMLangFontLink **  obj)

Definition at line 3931 of file mlang.c.

3932{
3933 TRACE("%p\n", obj);
3934
3935 if (!obj) return E_INVALIDARG;
3936
3938 {
3939 ERR("Failed to create global font link object.\n");
3940 return E_FAIL;
3941 }
3942
3943 return IUnknown_QueryInterface(font_link_global, &IID_IMLangFontLink, (void**)obj);
3944}
#define ERR(fmt,...)
Definition: precomp.h:57
#define E_INVALIDARG
Definition: ddrawi.h:101
BOOL WINAPI InitOnceExecuteOnce(_Inout_ PINIT_ONCE InitOnce, _In_ __callback PINIT_ONCE_FN InitFn, _Inout_opt_ PVOID Parameter, _Outptr_opt_result_maybenull_ LPVOID *Context)
Definition: InitOnce.c:12
static IUnknown * font_link_global
Definition: mlang.c:48
static BOOL WINAPI allocate_font_link_cb(PINIT_ONCE init_once, PVOID args, PVOID *context)
Definition: mlang.c:3926
static INIT_ONCE font_link_global_init_once
Definition: mlang.c:47

Referenced by test_GetGlobalFontLinkObject().

◆ IsConvertINetStringAvailable()

STDAPI 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()

STDAPI LcidToRfc1766A ( LCID  lcid,
LPSTR  pszRfc1766,
INT  nChar 
)

Definition at line 1235 of file mlang.c.

1239{
1240 TRACE("%04lx %p %u\n", lcid, pszRfc1766, nChar);
1241 if (!pszRfc1766)
1242 return E_INVALIDARG;
1243
1244 return lcid_to_rfc1766A(lcid, pszRfc1766, nChar);
1245}
LCID lcid
Definition: locale.c:5656
static HRESULT lcid_to_rfc1766A(LCID lcid, LPSTR rfc1766, INT len)
Definition: mlang.c:1181
int nChar
Definition: shlwapi.h:1074

◆ LcidToRfc1766W()

STDAPI LcidToRfc1766W ( LCID  lcid,
LPWSTR  pszRfc1766,
INT  nChar 
)

Definition at line 1247 of file mlang.c.

1251{
1252 TRACE("%04lx %p %u\n", lcid, pszRfc1766, nChar);
1253 if (!pszRfc1766)
1254 return E_INVALIDARG;
1255
1256 return lcid_to_rfc1766W(lcid, pszRfc1766, nChar);
1257}
static HRESULT lcid_to_rfc1766W(LCID lcid, LPWSTR rfc1766, INT len)
Definition: mlang.c:1208

Referenced by GetAcceptLanguagesW().

◆ Rfc1766ToLcidA()

STDAPI Rfc1766ToLcidA ( LCID lcid,
LPCSTR  rfc1766A 
)

Definition at line 1301 of file mlang.c.

1302{
1303 WCHAR rfc1766W[MAX_RFC1766_NAME + 1];
1304
1305 if (!rfc1766A)
1306 return E_INVALIDARG;
1307
1308 MultiByteToWideChar(CP_ACP, 0, rfc1766A, -1, rfc1766W, MAX_RFC1766_NAME);
1309 rfc1766W[MAX_RFC1766_NAME] = 0;
1310
1311 return Rfc1766ToLcidW(lcid, rfc1766W);
1312}
#define CP_ACP
Definition: compat.h:109
HRESULT WINAPI Rfc1766ToLcidW(LCID *pLocale, LPCWSTR pszRfc1766)
Definition: mlang.c:1281

◆ Rfc1766ToLcidW()

STDAPI Rfc1766ToLcidW ( LCID pLocale,
LPCWSTR  pszRfc1766 
)

Definition at line 1281 of file mlang.c.

1282{
1283 IEnumRfc1766 *enumrfc1766;
1284 HRESULT hr;
1285
1286 TRACE("(%p, %s)\n", pLocale, debugstr_w(pszRfc1766));
1287
1288 if (!pLocale || !pszRfc1766)
1289 return E_INVALIDARG;
1290
1291 hr = EnumRfc1766_create(0, &enumrfc1766);
1292 if (FAILED(hr))
1293 return hr;
1294
1295 hr = lcid_from_rfc1766(enumrfc1766, pLocale, pszRfc1766);
1296 IEnumRfc1766_Release(enumrfc1766);
1297
1298 return hr;
1299}
static HRESULT lcid_from_rfc1766(IEnumRfc1766 *iface, LCID *lcid, LPCWSTR rfc1766)
Definition: mlang.c:1259
static HRESULT EnumRfc1766_create(LANGID LangId, IEnumRfc1766 **ppEnum)
Definition: mlang.c:2457
#define FAILED(hr)
Definition: intsafe.h:51

Referenced by Rfc1766ToLcidA().