wchar_t new line?
Posted: Fri Oct 27, 2006 6:36 pm
Is it possible to put a new line in a wchar_t? I've tried the following:
L"blah\nblah"
but it just results in "blah blah"
L"blah\nblah"
but it just results in "blah blah"
Official forum of the Irrlicht Engine
https://irrlicht.sourceforge.io/forum/
Code: Select all
#include <stdio.h>
#include <wchar.h>
int main()
{
wprintf(L"blah\nblah\n");
return 0;
}
Maybe with your version of the compiler...L"\u000D\u000A" seems to work okay, at least here in windows
Code: Select all
C:\>type t.cpp && cl /c t.cpp
#include <wchar.h>
#include <stdio.h>
int main(void)
{
return wprintf(L"\u000d\u000a");
}
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.00.9466 for 80x86
Copyright (C) Microsoft Corporation 1984-2001. All rights reserved.
t.cpp
t.cpp(6) : warning C4129: 'u' : unrecognized character escape sequence
t.cpp(6) : warning C4129: 'u' : unrecognized character escape sequence
I'll try that in a bit. Thanks for the response .bitplane wrote:hmm looks like \x works instead of \u, can't try with irrlicht til i get home though
Damn, I thought you figured it out by now JP . It's pretty odd that you can't do any type of newline type stuff on a staticText (and edit box?). And pretty frustrating too. There's gotta be a simple way of doing it...JP wrote:That doesn't work either
Code: Select all
for ( int i = 0; i < (*m_sim).messages.size(); i++){
dataStream.str("");
dataStream.clear();
dataStream << (*m_sim).messages[i].strMessageText << flush;
result = result + "\n" + dataStream.str();
}
swtmp = result.c_str();
wstmp = swtmp.c_str();
m_textbox_message_text->setText(wstmp);
m_textbox_message_text->setLineFeed();
Code: Select all
while(*text)
{
n = (*text) - 32;
if ( n > Positions.size())
n = WrongCharacter;
Driver->draw2DImage(Texture, offset, Positions[n], clip, color, true);
offset.X += Positions[n].getWidth();
++text;
}
If I used it like you said (and like I was trying initially), it prints out a [] (box) character. No screenies atm but I can show one later. I'm using Dev-C++ with gcc (g++) to compile it on windows.bitplane wrote:Okay, it doesn't work for writing text using CGUIText, line breaks have to be inserted manually. see breakText() in CGUIStaticText.
it compares the text to a L'\n', which I is held internally as a token eg 0x000a (depending on compiler?) until its written out then its converted.. unless of course you're writing out to disk in binary mode (which the xml writer does), then the internal representation is written out.
in text mode \x0a's are replaced with the platform specific \n characters
using guiStaticText->setText(L"Some\nNewline") works fine for me, how were you using it JP?