SA-MP Forums Archive
[Include] Gametext/textdraw encoding fix - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] Gametext/textdraw encoding fix (/showthread.php?tid=397515)



Gametext/textdraw encoding fix - mooman - 05.12.2012

After some testing I've found that you can use the following characters in gametext and textdraws:
А Б В Д Ж З И Й К Л М Н О П Т У Ф Ц Щ Ъ Ы Ь Я а б в д ж з и й к л м н о п т у ф ц щ ъ ы ь С с ї Ў °
but you need to convert your string's encoding first to what I am calling the GTASA charset. The fix I'm providing will convert from Windows-1252 which is what people usually have as their ANSI charset if their language is written with the above characters.
Код:
stock convert_encoding(string[])
{
	new original[50] = {192,193,194,196,198,199,200,201,202,203,204,205,206,207,210,211,212,214,217,218,219,220,223,224,225,226,228,230,231,232,233,234,235,236,237,238,239,242,243,244,246,249,250,251,252,209,241,191,161,176};
	new fixed[50] = {128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,94,124};
	new len = strlen(string);
	for (new i; i < len; i++) {
		for(new j;j < 50;j++) {
			if(string[i] == original[j]) {
				string[i] = fixed[j];
				break;
			}
		}
	}
}
Example of usage:
Код:
convert_encoding(str);
GameTextForAll(str,5000,4);
So far I've only tested this only for strings from text files and command input as I don't like to write code containing non ASCII characters.

If you want to convert from another charset, you can use this list I compiled:
Код:
char	GTASA code point
А	128
Б	129
В	130
Д	131
Ж	132
З	133
И	134
Й	135
К	136
Л	137
М	138
Н	139
О	140
П	141
Т	142
У	143
Ф	144
Ц	145
Щ	146
Ъ	147
Ы	148
Ь	149
Я	150
а	151
б	152
в	153
д	154
ж	155
з	156
и	157
й	158
к	159
л	160
м	161
н	162
о	163
п	164
т	165
у	166
ф	167
ц	168
щ	169
ъ	170
ы	171
ь	172
С	173
с	174
ї	175
Ў	94
°	124
Hopefully this will help some of you. I'm aware it's not the most efficient function and doesn't even convert all of Windows-1252 but maybe if we're lucky someone better at coding than me will find it useful, rewrite it and share their solution.

Here's a screenshot of it in action:
http://i.imgur.com/T2Zzf.jpg


Re: Gametext/textdraw encoding fix - RajatPawar - 05.12.2012

The SS link is broken, and though not useful for me, this seems good..


Re: Gametext/textdraw encoding fix - DrSlett - 05.12.2012

Good, I go test it.


Re: Gametext/textdraw encoding fix - Caupo - 29.04.2014

Works for me. Big thanks, mooman.

PS: Also gave you some rep for it.


Re: Gametext/textdraw encoding fix - Niko_boy - 30.04.2014

i am not sure why we need to use them mostly. Ye i know some languages have them characters in their sentences but still.

Anyway good attempt


Re: Gametext/textdraw encoding fix - SimonItaly - 30.04.2014

Wow, I've never knew that, thanks!
We use accent marks in Italian language and sometimes it looks very bad if you replace и with e' in textdraws.


Re: Gametext/textdraw encoding fix - iWhite - 10.05.2014

How about ąčęėįљųū characters?


Re: Gametext/textdraw encoding fix - mooman - 10.05.2014

Those glyphs aren't in the GTASA font files so it's not possible AFAIK.


Re: Gametext/textdraw encoding fix - basicllsw - 28.07.2014

can use in thai language


Re: Gametext/textdraw encoding fix - Kaliber - 17.06.2016

Is it possible to use ©?