Raised This Month: $32 Target: $400
 8% 

Solved Doesn't SQL_ReadResult support UTF8?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
+ARUKARI-
AlliedModders Donor
Join Date: Jul 2004
Location: Japan
Old 06-02-2020 , 01:41   Doesn't SQL_ReadResult support UTF8?
Reply With Quote #1

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.
__________________
GitHub
SteamWishlist

六四天安門事件

Last edited by +ARUKARI-; 06-03-2020 at 07:39.
+ARUKARI- is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 06-02-2020 , 17:53   Re: Doesn't SQL_ReadResult support UTF8?
Reply With Quote #2

i have been using utf8mb4 for sql_setcharset and had no problems with database...maybe try that change and test?
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)
JocAnis is offline
+ARUKARI-
AlliedModders Donor
Join Date: Jul 2004
Location: Japan
Old 06-02-2020 , 18:42   Re: Doesn't SQL_ReadResult support UTF8?
Reply With Quote #3

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.
__________________
GitHub
SteamWishlist

六四天安門事件
+ARUKARI- is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-02-2020 , 20:26   Re: Doesn't SQL_ReadResult support UTF8?
Reply With Quote #4

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]
__________________
Bugsy is offline
+ARUKARI-
AlliedModders Donor
Join Date: Jul 2004
Location: Japan
Old 06-03-2020 , 04:17   Re: Doesn't SQL_ReadResult support UTF8?
Reply With Quote #5

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 = ん
__________________
GitHub
SteamWishlist

六四天安門事件

Last edited by +ARUKARI-; 06-03-2020 at 04:24.
+ARUKARI- is offline
+ARUKARI-
AlliedModders Donor
Join Date: Jul 2004
Location: Japan
Old 06-03-2020 , 07:41   Re: Doesn't SQL_ReadResult support UTF8?
Reply With Quote #6

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
__________________
GitHub
SteamWishlist

六四天安門事件

Last edited by +ARUKARI-; 06-03-2020 at 20:14.
+ARUKARI- is offline
peaces
Junior Member
Join Date: May 2008
Old 10-24-2021 , 21:21   Re: Doesn't SQL_ReadResult support UTF8?
Reply With Quote #7

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.
peaces is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-24-2021 , 23:01   Re: Doesn't SQL_ReadResult support UTF8?
Reply With Quote #8

Show the code and output you are getting.
__________________
Bugsy is offline
+ARUKARI-
AlliedModders Donor
Join Date: Jul 2004
Location: Japan
Old 10-25-2021 , 02:44   Re: Doesn't SQL_ReadResult support UTF8?
Reply With Quote #9

And what game are you trying to do it with?
It was HL1 that I had a problem with.
__________________
GitHub
SteamWishlist

六四天安門事件
+ARUKARI- is offline
peaces
Junior Member
Join Date: May 2008
Old 10-25-2021 , 05:51   Re: Doesn't SQL_ReadResult support UTF8?
Reply With Quote #10

Quote:
Originally Posted by Bugsy View Post
Show the code and output you are getting.
Quote:
Originally Posted by +ARUKARI- View Post
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

Last edited by peaces; 10-28-2021 at 02:08.
peaces is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:30.


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