AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   Solved Doesn't SQL_ReadResult support UTF8? (https://forums.alliedmods.net/showthread.php?t=324949)

+ARUKARI- 06-02-2020 01:41

Doesn't SQL_ReadResult support UTF8?
 
Does SQLX's SQL_ReadResult function not support UTF8?
Specifying utf8 in SQL_SetCharset does not apply to SQL_ReadResult.

If there is a way to get a multi-byte string in SQL, please let me know.

JocAnis 06-02-2020 17:53

Re: Doesn't SQL_ReadResult support UTF8?
 
i have been using utf8mb4 for sql_setcharset and had no problems with database...maybe try that change and test?

+ARUKARI- 06-02-2020 18:42

Re: Doesn't SQL_ReadResult support UTF8?
 
I'm trying to output the Japanese stored in sqlite to the screen now.
There is no problem with DB, but the string read by SQL_ReadResult is garbled.
I think it is SQL_ReadResult that has a problem because I confirmed that client_print and hudmessage can display Japanese.

Bugsy 06-02-2020 20:26

Re: Doesn't SQL_ReadResult support UTF8?
 
Are you able to see if any data is stored outside of the first byte with the UTF8 characters in your string?

Example:
PHP Code:

new szTest[] = "A";

server_print"[%d][%d][%d][%d]" szTest{0} , szTest{1} , szTest{2} , szTest{3} ); 

Output:
Code:

[0][0][0][65]

+ARUKARI- 06-03-2020 04:17

Re: Doesn't SQL_ReadResult support UTF8?
 
The resulting output looked like this.

Code:

[DEBUG]: [0][0][0][227]
[DEBUG]: [0][0][0][129]
[DEBUG]: [0][0][0][147]
[DEBUG]: [0][0][0][227]
[DEBUG]: [0][0][0][130]
[DEBUG]: [0][0][0][147]
[DEBUG]: [0][0][0][227]
[DEBUG]: [0][0][0][129]
[DEBUG]: [0][0][0][171]
[DEBUG]: [0][0][0][227]
[DEBUG]: [0][0][0][129]
[DEBUG]: [0][0][0][161]
[DEBUG]: [0][0][0][227]
[DEBUG]: [0][0][0][129]
[DEBUG]: [0][0][0][175]
[DEBUG]: [0][0][0][227]
[DEBUG]: [0][0][0][128]
[DEBUG]: [0][0][0][129]
[DEBUG]: [0][0][0][227]
[DEBUG]: [0][0][0][131]
[DEBUG]: [0][0][0][150]
[DEBUG]: [0][0][0][227]
[DEBUG]: [0][0][0][131]
[DEBUG]: [0][0][0][169]
[DEBUG]: [0][0][0][227]
[DEBUG]: [0][0][0][131]
[DEBUG]: [0][0][0][131]
[DEBUG]: [0][0][0][227]
[DEBUG]: [0][0][0][130]
[DEBUG]: [0][0][0][175]
[DEBUG]: [0][0][0][227]
[DEBUG]: [0][0][0][131]

Well, perhaps this is how it is?
UTF8 (3byte)
Code:

[[227][129][147]], [[227][130][147]], ...
0xE3 81 93 = こ,  0xE3 82 93 = ん


+ARUKARI- 06-03-2020 07:41

Re: Doesn't SQL_ReadResult support UTF8?
 
I was mistaken.
Close this thread, as client_print outputs no problem.
The garbled text only occurs with HL's HudMessage, so the cause seems to be on the HudMessage side.

https://github.com/ValveSoftware/halflife/issues/515

peaces 10-24-2021 21:21

Re: Doesn't SQL_ReadResult support UTF8?
 
If read UTF-8 characters from the database, it seems that the characters cannot be displayed normally in the game.
Is there a solution? thanks.

Bugsy 10-24-2021 23:01

Re: Doesn't SQL_ReadResult support UTF8?
 
Show the code and output you are getting.

+ARUKARI- 10-25-2021 02:44

Re: Doesn't SQL_ReadResult support UTF8?
 
And what game are you trying to do it with?
It was HL1 that I had a problem with.

peaces 10-25-2021 05:51

Re: Doesn't SQL_ReadResult support UTF8?
 
Quote:

Originally Posted by Bugsy (Post 2761581)
Show the code and output you are getting.

Quote:

Originally Posted by +ARUKARI- (Post 2761593)
And what game are you trying to do it with?
It was HL1 that I had a problem with.

Code:

new str[32]
                        SQL_ReadResult(query, 0, str, 31)
       
                        if(get_pcvar_num(pi_show_who) == 1)
                        {
                                new players[32], playersnum
                                get_players(players, playersnum, "ch")
                                for(new i = 0; i < playersnum; i++)
                                {
                                        new player = players[i]
                                        if(is_user_admin(player))
                                        {
                                                if(get_pcvar_num(pi_hudmsg) == 0)
                                                {
                                                        client_print(player, print_chat, "%L", LANG_PLAYER, "JOIN_MSG", name)
                                                        client_print(player, print_chat, "%L", LANG_PLAYER, "JOIN_MSG2", str)
                                                }
                                                else
                                                {
                                                        new message[192]
                                                        format(message, 191, "%L", LANG_PLAYER, "JOIN_HUDMSG", name , str)
                                                        set_hudmessage(0, 255, 0, 0.05, 0.30, 0, 6.0, 5.0 , 0.5, 0.15, -1)
                                                        ShowSyncHudMsg(player, MyMsgSync, "%s", message)
                                                }
                                        }
                                }
                        }

SQL_ReadResult
If read UTF-8 characters from the database, it seems that the characters cannot be displayed normally in the cstrike


All times are GMT -4. The time now is 06:10.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.