Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6748985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:38:04+00:00 2026-05-26T12:38:04+00:00

I’m trying to figure out the safest way to retrieve unicode data in a

  • 0

I’m trying to figure out the safest way to retrieve unicode data in a unified method from remote computers and make sure that data stays consistent and readable.

Computer A: Chinese user, mixed English Windows 7, some registry values contain Chinese letters like L”您好”

Computer B: US English, no unicode values returned from my functions

Computer C: Introduces an agent to Computer A and B.

The agent: assesses the health and security of the computer from the inside. One unicode aware section is simply getting registry values i.e:

int Utilities::GetRegistryStringValue(HKEY h_sub_key, WCHAR* value_name, wstring &result)
{
DWORD cbData = 8;
LPDWORD type = NULL;

//Get the size and type of the key
long err = RegQueryValueEx(h_sub_key, value_name, NULL, type, NULL, &cbData);

if (err != ERROR_SUCCESS)
{
    if (err != ERROR_FILE_NOT_FOUND)
        debug->DebugMessage(Error::GetErrorMessageW(err));
    return err;
}

result.resize(cbData / sizeof(WCHAR));

LPWSTR res = new WCHAR[(cbData + sizeof(L'\0')) / sizeof(WCHAR)];

err = RegQueryValueEx(h_sub_key, value_name, NULL, NULL, (LPBYTE) &res[0], &cbData);

if(err != ERROR_SUCCESS && err != ERROR_FILE_NOT_FOUND)
{
    debug->DebugMessage(Error::GetErrorMessageW(err));
    return err;
}

res[cbData / sizeof(WCHAR)] = L'\0';

result = wstring(res);

return ERROR_SUCCESS;

}

Those values will be stored in an XML file.
Should that XML file be in UTF16 or UTF8?
Am I going to need to pass the remote system’s code page back for translation?
What other issues might I have?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:38:05+00:00Added an answer on May 26, 2026 at 12:38 pm

    UTF8 is more standard (for networking) because it does not have endian issues. For UTF16 you’ll need to specify an endian-ness for the transmission. If you’re using a unicode format, you do not need a code page.

    You can do the translation with standard windows calls like WideCharToMultiByte if they’re on windows machines.

    std::wstring buffer_with_utf16;
    const char DefaultChar = 1; //not null, but not normal either
    bool had_conversion_error = false;    
    int alength = WideCharToMultiByte(CP_UTF8, 0, 
                  buffer_with_utf16.cstr(), buffer_with_utf16.size(),
                  NULL, 0, 
                  &DefaultChar, &had_conversion_error);
    if (alength == 0)
        throw std::logic_error("Bad UTF8 conversion"); //use GetLastError
    std::string buffer_with_utf8(alength+1);
    int error = WideCharToMultiByte(CP_UTF8, 0, 
                  buffer_with_utf16.cstr(), buffer_with_utf16.size(),
                  &buffer_with_utf8[0], buffer_with_utf8.size(), 
                  &DefaultChar, &had_conversion_error);
    if (error == 0)
        throw std::logic_error("Bad UTF8 conversion"); //use GetLastError
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I am using jsonparser to parse data and images obtained from json response. When
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.