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 7042127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:07:50+00:00 2026-05-28T02:07:50+00:00

I use this function to get a line of text from a rich edit

  • 0

I use this function to get a line of text from a rich edit control.

CString RichEditCtrlEx::getLine(int charIndex) const
{
CString retval;

int lineIndex = LineFromChar(charIndex);
ASSERT(lineIndex>=0 && lineIndex<GetLineCount());
int sizeOfLine = LineLength(charIndex);

TCHAR* buffer = new TCHAR[sizeOfLine + 148];

ASSERT(buffer);

if (buffer) {

    memset(buffer,0,sizeOfLine + 148);
    *((int *)buffer) = sizeOfLine;

    GetLine(lineIndex, buffer);
    retval = buffer;
    delete[] buffer;
}

return retval;  
}

The function GetLine:

_AFXWIN_INLINE int CEdit::GetLine(_In_ int nIndex, _Out_ LPTSTR lpszBuffer) const
{ ASSERT(::IsWindow(m_hWnd)); return (int)::SendMessage(m_hWnd, EM_GETLINE, nIndex, (LPARAM)lpszBuffer); 

For the most part it works perfectly. However if the text in the rich edit control contains special characters (e.g. “拿듬壴竒” ) the characters which are returned are wrong (when using the characters in the example the result is “ÿìôÒ”)

Does the EM_GETLINE message allow these special characters? Or do I need a different approach?

  • 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-28T02:07:51+00:00Added an answer on May 28, 2026 at 2:07 am

    Could you give an example of text for which your code works? The example text you give for failure indicates that the upper 8 bits of the characters is getting zeroed out.

    拿 (U+62FF) -> ÿ (U+00FF)
    듬 (U+B4EC) -> ì (U+00EC)
    壴 (U+58F4) -> ô (U+00F4)
    竒 (U+7AD2) -> Ò (U+00D2)
    

    If the text that your code ‘works’ for is all in the range U+0000 to U+00FF (which covers characters used in the Americas and Western Europe) then you wouldn’t notice a problem even if you’re doing something wrong. This would indicate that this is probably not a problem with getting text from the control, but instead a problem with something your program does with the text elsewhere.

    Assuming your program defines the UNICODE macros then TCHAR is wchar_t, which is two bytes on Windows. Make sure you’re not mistakenly treating it as a one byte char anywhere, because that could easly truncate the character values the way you describe. Jim Rhodes already pointed out one area where you’re not taking this into account.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use the following jquery statements but i get error in this function onGetDataSuccess(result)
I am trying to use this function from a COM API which enables the
I currently use this function to wrap executing commands and logging their execution, and
I want to use this function EnumWindows(EnumWindowsProc, NULL);. The EnumWindowsProc is a Callback function:
I want to use this function: http://www.frankmacdonald.co.uk/php/post-to-wordpress-with-php.html Its used to post to Wordpress using
I use this script to equalize heights of elements: (function ($) { $.fn.autoheight =
I use this pseudo-class to make Ajax request to server: function RequestManager(url, params, success,
I generally use this in jquery $(document).ready(function() { //stuff } I was just on
I used to use this script for jquery email obfuscation: $(.replaceAt).replaceWith(@); $(.obfuscate).each(function () {
I came across the function InterlockedExchange and was wondering when I should use this

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.