Skip to content

Commit

Permalink
fix utf8 converting
Browse files Browse the repository at this point in the history
  • Loading branch information
smok95 committed Jul 14, 2021
1 parent 122a957 commit 9c7210e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 23 deletions.
8 changes: 4 additions & 4 deletions Resource.rc
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,0,5,0
PRODUCTVERSION 0,0,5,0
FILEVERSION 0,0,6,0
PRODUCTVERSION 0,0,6,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -69,12 +69,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "TODO: <ȸ�� �̸�>"
VALUE "FileDescription", "TODO: <���� ����>"
VALUE "FileVersion", "0.0.5.0"
VALUE "FileVersion", "0.0.6.0"
VALUE "InternalName", "kw_.dll"
VALUE "LegalCopyright", "Copyright (C) 2021 Kim, Jong-Kook"
VALUE "OriginalFilename", "kw_.dll"
VALUE "ProductName", "TODO: <��ǰ �̸�>"
VALUE "ProductVersion", "0.0.5.0"
VALUE "ProductVersion", "0.0.6.0"
END
END
BLOCK "VarFileInfo"
Expand Down
4 changes: 2 additions & 2 deletions example/exampleConsole/exampleConsole.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "kw_.h"
#pragma comment(lib, "kw_.lib")

void CALLBACK OnEventConnect(long errCode) {
void OnEventConnect(long errCode) {
if (errCode == 0) {
puts("로그인 성공");

Expand All @@ -14,7 +14,7 @@ void CALLBACK OnEventConnect(long errCode) {
}
else {
puts("로그인 실패");
exit(0);
kw_Disconnect();
}
}

Expand Down
30 changes: 15 additions & 15 deletions include/kw_.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,42 +215,42 @@ KW_API void kw_SetRealRemoveA(PCSTR strScrNo, PCSTR strDelCode);
KW_API long kw_GetMarketTypeW(PCWSTR sTrCode);
KW_API long kw_GetMarketTypeA(PCSTR sTrCode);

typedef void (CALLBACK* kw_OnEventConnect)(long nErrCode);
typedef void (*kw_OnEventConnect)(long nErrCode);

typedef void (CALLBACK* kw_OnReceiveTrDataW)(PCWSTR sScrNo, PCWSTR sRQName,
typedef void (*kw_OnReceiveTrDataW)(PCWSTR sScrNo, PCWSTR sRQName,
PCWSTR sTrCode, PCWSTR sRecordName, PCWSTR sPrevNext, long nDataLength,
PCWSTR sErrorCode, PCWSTR sMessage, PCWSTR sSplmMsg);
typedef void (CALLBACK* kw_OnReceiveTrDataA)(PCSTR sScrNo, PCSTR sRQName,
typedef void (*kw_OnReceiveTrDataA)(PCSTR sScrNo, PCSTR sRQName,
PCSTR sTrCode, PCSTR sRecordName, PCSTR sPrevNext, long nDataLength,
PCSTR sErrorCode, PCSTR sMessage, PCSTR sSplmMsg);

typedef void (CALLBACK* kw_OnReceiveRealDataW)(PCWSTR sRealKey,
typedef void (*kw_OnReceiveRealDataW)(PCWSTR sRealKey,
PCWSTR sRealType, PCWSTR sRealData);
typedef void (CALLBACK* kw_OnReceiveRealDataA)(PCSTR sRealKey,
typedef void (*kw_OnReceiveRealDataA)(PCSTR sRealKey,
PCSTR sRealType, PCSTR sRealData);

typedef void (CALLBACK* kw_OnReceiveMsgW)(PCWSTR sScrNo, PCWSTR sRQName,
typedef void (*kw_OnReceiveMsgW)(PCWSTR sScrNo, PCWSTR sRQName,
PCWSTR sTrCode, PCWSTR sMsg);
typedef void (CALLBACK* kw_OnReceiveMsgA)(PCSTR sScrNo, PCSTR sRQName,
typedef void (*kw_OnReceiveMsgA)(PCSTR sScrNo, PCSTR sRQName,
PCSTR sTrCode, PCSTR sMsg);

typedef void (CALLBACK* kw_OnReceiveChejanDataW)(PCWSTR sGubun, long nItemCnt,
typedef void (*kw_OnReceiveChejanDataW)(PCWSTR sGubun, long nItemCnt,
PCWSTR sFIdList);
typedef void (CALLBACK* kw_OnReceiveChejanDataA)(PCSTR sGubun, long nItemCnt,
typedef void (*kw_OnReceiveChejanDataA)(PCSTR sGubun, long nItemCnt,
PCSTR sFIdList);

typedef void (CALLBACK* kw_OnReceiveRealConditionW)(PCWSTR sTrCode,
typedef void (*kw_OnReceiveRealConditionW)(PCWSTR sTrCode,
PCWSTR strType, PCWSTR strConditionName, PCWSTR strConditionIndex);
typedef void (CALLBACK* kw_OnReceiveRealConditionA)(PCSTR sTrCode,
typedef void (*kw_OnReceiveRealConditionA)(PCSTR sTrCode,
PCSTR strType, PCSTR strConditionName, PCSTR strConditionIndex);

typedef void (CALLBACK* kw_OnReceiveTrConditionW)(PCWSTR sScrNo,
typedef void (*kw_OnReceiveTrConditionW)(PCWSTR sScrNo,
PCWSTR strCodeList, PCWSTR strConditionName, int nIndex, int nNext);
typedef void (CALLBACK* kw_OnReceiveTrConditionA)(PCSTR sScrNo,
typedef void (*kw_OnReceiveTrConditionA)(PCSTR sScrNo,
PCSTR strCodeList, PCSTR strConditionName, int nIndex, int nNext);

typedef void (CALLBACK* kw_OnReceiveConditionVerW)(long lRet, PCWSTR sMsg);
typedef void (CALLBACK* kw_OnReceiveConditionVerA)(long lRet, PCSTR sMsg);
typedef void (*kw_OnReceiveConditionVerW)(long lRet, PCWSTR sMsg);
typedef void (*kw_OnReceiveConditionVerA)(long lRet, PCSTR sMsg);

KW_API void kw_SetOnEventConnect(kw_OnEventConnect handler);

Expand Down
2 changes: 1 addition & 1 deletion src/kw_.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ wchar_t* utf8ToUnicode(const char* utf8) {
const int sizeNeeded = MultiByteToWideChar(CP_UTF8, 0, utf8, len, nullptr, 0);
if (sizeNeeded == 0) return nullptr;

wchar_t* unicode = (wchar_t*)calloc(sizeNeeded, sizeof(wchar_t));
wchar_t* unicode = (wchar_t*)calloc(sizeNeeded+1, sizeof(wchar_t));
MultiByteToWideChar(CP_UTF8, 0, utf8, len, unicode, sizeNeeded);
return unicode;
}
Expand Down
4 changes: 3 additions & 1 deletion src/kwapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,9 @@ class kwapi :
inline char* bstrToString(BSTR bstr) {
if (useUtf8_) {
const UINT len = SysStringLen(bstr);
if (len == 0) return nullptr;
if (len == 0) {
return _strdup("");
}
const int sizeNeeded = WideCharToMultiByte(CP_UTF8, 0, bstr, len,
nullptr, 0, nullptr, nullptr);
char* utf8 = (char*)calloc(sizeNeeded, sizeNeeded);
Expand Down

0 comments on commit 9c7210e

Please sign in to comment.