Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chinese charset question? #40

Closed
gzhwl opened this issue Feb 3, 2021 · 2 comments
Closed

Chinese charset question? #40

gzhwl opened this issue Feb 3, 2021 · 2 comments
Labels
not a bug This issue is incorrect

Comments

@gzhwl
Copy link

gzhwl commented Feb 3, 2021

Hello, I'm a Chinese developer, I use HexCtrl in my MFC App, using it with 'Building From The Sources' type,create window with these code:

RECT rcClient = { 0 };
::GetClientRect(GetSafeHwnd(), &rcClient);
HEXCREATESTRUCT hcs;
hcs.enCreateMode = EHexCreateMode::CREATE_CHILD;
hcs.hwndParent = m_hWnd;
hcs.rect = rcClient;
if (m_HexCtrl->Create(hcs))
{
// Set China locale
m_HexCtrl->SetEncoding(936);
// Init string whith Chinese Char
std::string str = "0123456789,零一二三四五六七八九十,零壹贰叁肆伍陆柒捌玖拾";
HEXDATASTRUCT hds;
hds.pData = (std::byte*)str.data();
hds.ullDataSize = str.size();

  m_HexCtrl->SetData(hds);
  m_HexCtrl->SetEncoding(936);
  // INT dpiX = GetDeviceCaps(hScreen, LOGPIXELSX);
  // float m_dScale = dpiX * 100.00f / 96.00f;
  // m_dScale = 2.0
  // m_HexCtrl->SetFontSize(UINT(14 * 2));

}

these code compiled ok, But after I run the App and click the data shown in the HEX View wnd, The data Changed random,is it a bug?

@jovibor
Copy link
Owner

jovibor commented Feb 3, 2021

Hi, you are using a local stack variable std::string str = to set the data, no wonder it doesn't work. It destroys as soon as it goes out of the declaration scope.
You must either make it static or declare it as a class member (or global).

@jovibor jovibor added the not a bug This issue is incorrect label Feb 3, 2021
@gzhwl
Copy link
Author

gzhwl commented Feb 3, 2021

Thanks, I changed it to 'static' declare, It works !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not a bug This issue is incorrect
Projects
None yet
Development

No branches or pull requests

2 participants