wchar_t new line?
wchar_t new line?
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"
Hi,
on my linux box:
prints:
blah
blah
Bye
on my linux box:
Code: Select all
#include <stdio.h>
#include <wchar.h>
int main()
{
wprintf(L"blah\nblah\n");
return 0;
}
blah
blah
Bye
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
So is there an easy way of accomplishing the task of doing a newline / CR / LF in a staticText? Haven't tried an edit box yet but I'm assuming the same things happens when trying to do a standard "\n".
Currently I'm using a listbox because I was tired of wasting time looking through code and chat examples.
Anyone? Thanks in advance for any replies.
Currently I'm using a listbox because I was tired of wasting time looking through code and chat examples.
Anyone? Thanks in advance for any replies.
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
Xhrit from IRC showed me an example that parses the text but I haven't tried it yet (or tried to understand it yet for that matter):
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();
My 2 cents.
Looking in irrlicht source the drawing text routine is CGUIFont::draw(...) in
CGUIFont.cpp.
It does:
So, how can it understands your "\n"?
Bye
Looking in irrlicht source the drawing text routine is CGUIFont::draw(...) in
CGUIFont.cpp.
It does:
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;
}
Bye
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?
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?
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?
I'll take a look at breakText a bit later. Thanks bitplane.