SA-MP Forums

SA-MP Forums (https://forum.sa-mp.com/index.php)
-   Includes (https://forum.sa-mp.com/forumdisplay.php?f=83)
-   -   [Include] Gametext/textdraw encoding fix (https://forum.sa-mp.com/showthread.php?t=397515)

mooman 05/12/2012 12:17 PM

Gametext/textdraw encoding fix
 
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.
Code:

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:
Code:

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:
Code:

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

RajatPawar 05/12/2012 12:39 PM

Re: Gametext/textdraw encoding fix
 
The SS link is broken, and though not useful for me, this seems good..

DrSlett 05/12/2012 02:37 PM

Re: Gametext/textdraw encoding fix
 
Good, I go test it.

Caupo 29/04/2014 09:34 PM

Re: Gametext/textdraw encoding fix
 
Works for me. :) Big thanks, mooman.

PS: Also gave you some rep for it. :)

Niko_boy 30/04/2014 10:18 AM

Re: Gametext/textdraw encoding fix
 
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

SimonItaly 30/04/2014 09:44 PM

Re: Gametext/textdraw encoding fix
 
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.

iWhite 10/05/2014 03:50 PM

Re: Gametext/textdraw encoding fix
 
How about ąčęėįųū characters?

mooman 10/05/2014 03:55 PM

Re: Gametext/textdraw encoding fix
 
Those glyphs aren't in the GTASA font files so it's not possible AFAIK.

basicllsw 28/07/2014 06:55 AM

Re: Gametext/textdraw encoding fix
 
can use in thai language

Kaliber 17/06/2016 05:38 PM

Re: Gametext/textdraw encoding fix
 
Is it possible to use ?


All times are GMT. The time now is 09:37 AM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.