Half-Life и Adrenaline Gamer форум http://aghl.ru/forum/ |
|
UTF-8 in Chat check letters http://aghl.ru/forum/viewtopic.php?f=12&t=3313 |
Страница 1 из 3 |
Автор: | abdobiskra [ 11 май 2023, 16:12 ] |
Заголовок сообщения: | UTF-8 in Chat check letters |
Hi, first of all Welcome back to the forum again strlen()Not supports multi-byte characters (UTF-8 ). (is there another function similar supports multi-byte?) I want an example of how strfind() can determine the position of a letter in a word? I want to replace the word except for the last letter, for example, how do I do that? |
Автор: | Lev [ 15 май 2023, 12:27 ] |
Заголовок сообщения: | Re: UTF-8 in Chat check letters |
Hi! https://www.amxmodx.org/api/string/__functions No words about no support of UTF-8 for strlen. In real, strlen works for UTF-8 strings. It returns length in bytes (not chars). To find, just use strfind with the same multi-byte string you are trying to find. It will search for byte to byte match. |
Автор: | abdobiskra [ 16 май 2023, 02:04 ] |
Заголовок сообщения: | Re: UTF-8 in Chat check letters |
-How can I replace all letters in each word in the chat except for the last letter of each word Using the available functions? -I specified the last letter through this function but it only works with latin (english) letters But it didn't give the result I'm looking for in the end this my code and whati try too: Код: new Separate_letters_Symbol[][] = { |
Автор: | Lev [ 24 май 2023, 19:08 ] |
Заголовок сообщения: | Re: UTF-8 in Chat check letters |
Why do you use i variable name for outer and inner for cycles? It is a mistake. I dunno what you are trying to do. Nor I understand why you use MultiByteToWideChar, WideCharToMultiByte, ReverseString. Probably this is about right-to-left writing, but I dunno how people chat in these languages. Without correct description I can't help. |
Автор: | Lev [ 28 май 2023, 15:26 ] |
Заголовок сообщения: | Re: UTF-8 in Chat check letters |
The first thing you should try to achive is to output text to the client screen so it looks as required. For that I advise you to move to the byte level. If you see that at least part of the sentence looks correctly - capture it and analyze the byte order. Check the end letter case, probably you will be able to add some bytes (text, spaces, dots) so the last letter will appear not separated. After you will get the output byte sequence that will looks good, you can start to deal with the input byte sequence to convert it in the correct form. |
Автор: | abdobiskra [ 08 июн 2023, 00:20 ] |
Заголовок сообщения: | Re: UTF-8 in Chat check letters |
Lev писал(а): The first thing you should try to achive is to output text to the client screen so it looks as required. Код: MultiByteToWideChar(said, said_to_utf16)In this part of the above code I actually captured the chat line as I should see it (said_to_utf8) (the position of the letters in the word and the position of the words were converted from right to left, then the non-connected letters were replaced and converted to connected letters in the word) Lev писал(а): For that I advise you to move to the byte level. If you see that at least part of the sentence looks correctly - capture it and analyze the byte order. Check the end letter case, probably you will be able to add some bytes (text, spaces, dots) so the last letter will appear not separated. Код: new last_leter[192]Yes, in this part of the code, I think I did that by capturing the last letter of the word in the chat through its last output in the previous code, then I returned the last letter of a connected letter to a separate letter (contrary to what I did in the previous code) Код: new said_utf8[192];//First LettersHere I captured the word except for the last letter and then output them in one interface in the results ( i.e. the last letter that was previously replaced with the word without the last letter) The results are somewhat unsatisfactory because there is a space between the last letter and the word. Result what i get : م(space)سلا "As attached in the picture" Result what i need : سلام "like as defult output (UP)result but form of last letter should be (م) not (مـ) " I am wondering if there is another way to analyze the letters inside each word and ignore the replacement of the last letter, i.e. leave it as it is (i.e. replace the letters of words without replacing the last letter of it) Lev писал(а): After you will get the output byte sequence that will looks good, you can start to deal with the input byte sequence to convert it in the correct form. Could you give me a simple example to make it clearer?
|
Автор: | Lev [ 08 июн 2023, 15:27 ] |
Заголовок сообщения: | Re: UTF-8 in Chat check letters |
abdobiskra писал(а): Could you give me a simple example to make it clearer? You can start with just single-line plugin:Код: client_print( "Your text in right-to-left-form" )And check how it looks on the client. If you will manage to output text correctly, bring that string from the plugin and chat captured string that you wish to convert to that output. And then I probably could help you to mangle it. |
Автор: | abdobiskra [ 09 июн 2023, 03:00 ] | ||
Заголовок сообщения: | Re: UTF-8 in Chat check letters | ||
I think I did it above? (Valve) : It's how letters and words appear from left to right in a normal chat (Plugin) : After the modification to the chat through the functions available in the plugin The results of the plugin are missing the last letter, either ignoring its replacement or returning it to its shape .. or any method that works Цитата: (Valve) Abdo : م ك ل ا ح () ف ي ك () م ك ي ل ع () م ال س
(Plugin) Abdo : سلامـ عليكمـ كيفـ حالكمـ I want it like that : سلام عليكم كيف حالكم You can notice the last letter of the words as i want them
|
Автор: | Lev [ 13 июн 2023, 22:36 ] |
Заголовок сообщения: | Re: UTF-8 in Chat check letters |
Byte-to-byte comparision of two texts reveals extra bytes. Вложение: Top text is "سلامـ عليكمـ كيفـ حالكمـ", bottom: "سلام عليكم كيف حالكم" Try to remove these bytes from string. |
Страница 1 из 3 | Часовой пояс: UTC + 5 часов [ Летнее время ] |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |