logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Text retrieved from DB

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Technical support
View previous topic :: View next topic  
Author Message
Urlord



Joined: 17 Nov 2006
Posts: 122

PostPosted: Thu Sep 20, 2007 15:12    Post subject: Text retrieved from DB Reply with quote

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
View user's profile Send private message Send e-mail
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Thu Sep 20, 2007 15:20    Post subject: Reply with quote

What do you get if you write the string from the DB to the logfile ?
_________________
Papillon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Gryphyn



Joined: 20 Jan 2005
Posts: 431

PostPosted: Thu Sep 20, 2007 15:41    Post subject: Re: Text retrieved from DB Reply with quote

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
View user's profile Send private message
Urlord



Joined: 17 Nov 2006
Posts: 122

PostPosted: Thu Sep 20, 2007 16:42    Post subject: Re: Text retrieved from DB Reply with quote

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
View user's profile Send private message Send e-mail
Urlord



Joined: 17 Nov 2006
Posts: 122

PostPosted: Thu Sep 20, 2007 17:12    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Urlord



Joined: 17 Nov 2006
Posts: 122

PostPosted: Thu Sep 20, 2007 18:10    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Gryphyn



Joined: 20 Jan 2005
Posts: 431

PostPosted: Thu Sep 20, 2007 23:41    Post subject: Reply with quote

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
View user's profile Send private message
elven



Joined: 28 Jul 2006
Posts: 259
Location: Germany

PostPosted: Fri Sep 21, 2007 9:23    Post subject: Re: Text retrieved from DB Reply with quote

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
View user's profile Send private message
Urlord



Joined: 17 Nov 2006
Posts: 122

PostPosted: Fri Sep 21, 2007 17:08    Post subject: Reply with quote

In my testing with NWN2, SendMessageToPC() does place linebreaks for \n.
_________________
Jim (aka, Urlord)
Visit the Persistent World of Nymri
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Technical support All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group