View previous topic :: View next topic |
Author |
Message |
Urlord
Joined: 17 Nov 2006 Posts: 122
|
Posted: Thu Sep 20, 2007 15:12 Post subject: Text retrieved from DB |
|
|
Can any of you think of a reason why this is happening?
When I hard code the following:
SendMessageToPC(oPC, "Test\nTest\nTest");
I get:
Test
Test
Test
But when I pull that exact string from the database and display it, I get this:
Test\nTest\nTest
Could it be that the database replaces the \ character with an encoded one or something? Any clues guys? I am stumped. _________________ Jim (aka, Urlord)
Visit the Persistent World of Nymri |
|
Back to top |
|
|
Papillon x-man
Joined: 28 Dec 2004 Posts: 1060 Location: Germany
|
Posted: Thu Sep 20, 2007 15:20 Post subject: |
|
|
What do you get if you write the string from the DB to the logfile ? _________________ Papillon |
|
Back to top |
|
|
Gryphyn
Joined: 20 Jan 2005 Posts: 431
|
Posted: Thu Sep 20, 2007 15:41 Post subject: Re: Text retrieved from DB |
|
|
Urlord wrote: | Can any of you think of a reason why this is happening?
When I hard code the following:
SendMessageToPC(oPC, "Test\nTest\nTest");
I get:
Test
Test
Test
But when I pull that exact string from the database and display it, I get this:
Test\nTest\nTest
Could it be that the database replaces the \ character with an encoded one or something? Any clues guys? I am stumped. |
The "\" character is stripped before it gets to NWNX4. Naught you can do about it. My spawn plugin lets you replace the "|" character with a "\" character as an alternative/work-around.
It you added the string directly into MySQL it's an encoding issue (UCS-2 vs UTF-8) you need to convert the string value to UTF-8 encoding before it gets to NWNX4.
Cheers
Gryphyn |
|
Back to top |
|
|
Urlord
Joined: 17 Nov 2006 Posts: 122
|
Posted: Thu Sep 20, 2007 16:42 Post subject: Re: Text retrieved from DB |
|
|
Gryphyn wrote: | It you added the string directly into MySQL it's an encoding issue (UCS-2 vs UTF-8 ) you need to convert the string value to UTF-8 encoding before it gets to NWNX4. |
I did add it directly to the database. How do I convert it to UTF-8 when retrieving it? _________________ Jim (aka, Urlord)
Visit the Persistent World of Nymri |
|
Back to top |
|
|
Urlord
Joined: 17 Nov 2006 Posts: 122
|
Posted: Thu Sep 20, 2007 17:12 Post subject: |
|
|
I did some research and found that I needed to change the column character set in the database.
So, I altered the column to use character set utf8 and column collate to utf_8_general_ci.
However, it still isn't working.
Any suggestions? _________________ Jim (aka, Urlord)
Visit the Persistent World of Nymri |
|
Back to top |
|
|
Urlord
Joined: 17 Nov 2006 Posts: 122
|
Posted: Thu Sep 20, 2007 18:10 Post subject: |
|
|
Intrestingly enough, I went back and edited the text data in the database.
When I copy data from notepad, the line breaks show up as the paragraph symbol followed by a large dot (I can't copy an paste it in here).
This is read in properly by NWNX4 and correctly interpreted by NWN2 as a linebreak. So, for my application, I have no need to use \n or any other work around for linebreaks. I currently have that column set to character set UTF-8 and Collate to utf8_unicode_ci
But, it does seem to me that there should be a way for NWNX to convert all metacharacters from UCS-2 to UTF-8 when it gets them from the database. Just a thought as I do not have a clue why this is not possible. _________________ Jim (aka, Urlord)
Visit the Persistent World of Nymri |
|
Back to top |
|
|
Gryphyn
Joined: 20 Jan 2005 Posts: 431
|
Posted: Thu Sep 20, 2007 23:41 Post subject: |
|
|
Urlord wrote: | But, it does seem to me that there should be a way for NWNX to convert all metacharacters from UCS-2 to UTF-8 when it gets them from the database. Just a thought as I do not have a clue why this is not possible. |
There is,
But you need to recompile the plugin with some different options.
Set MBCS on for the project, (not UNICODE)
for returning data - use .uft8_str() instead of .c_str()
I've had some success with this, but it's been flaky between updates of NWNX4 & wxWidgets.
Cheers
Gryphyn |
|
Back to top |
|
|
elven
Joined: 28 Jul 2006 Posts: 259 Location: Germany
|
Posted: Fri Sep 21, 2007 9:23 Post subject: Re: Text retrieved from DB |
|
|
Urlord wrote: | Can any of you think of a reason why this is happening?
When I hard code the following:
SendMessageToPC(oPC, "Test\nTest\nTest");
I get:
Test
Test
Test
But when I pull that exact string from the database and display it, I get this:
Test\nTest\nTest
Could it be that the database replaces the \ character with an encoded one or something? Any clues guys? I am stumped. |
The original nwn bytecode compiler transforms this into three calls, if I recall correctly. SendMessageToPC() does not support linebreaks natively.
Maybe I am wrong though. It's just an idea. Haven't used the original compiler in a while. |
|
Back to top |
|
|
Urlord
Joined: 17 Nov 2006 Posts: 122
|
Posted: Fri Sep 21, 2007 17:08 Post subject: |
|
|
In my testing with NWN2, SendMessageToPC() does place linebreaks for \n. _________________ Jim (aka, Urlord)
Visit the Persistent World of Nymri |
|
Back to top |
|
|
|