Raised This Month: $51 Target: $400
 12% 

How to check letters and words in sentences?


Post New Thread Reply   
 
Thread Tools Display Modes
abdobiskra
Veteran Member
Join Date: Jul 2014
Location: Algeria
Old 07-05-2023 , 18:47   Re: How to check letters and words in sentences?
Reply With Quote #21

Another question, is it possible to replace two characters consisting of, for example, 6 bytes, with a character consisting of 2 or 3 bytes?
(I want to delete two characters and replace them with one by deleting the bytes after the condition is met)
What i do :
PHP Code:
                        if (said_to_utf8[i+2] == 0x8E  &&  said_to_utf8[i+5] == 0x9F)
                        {
                            
                            
said_to_utf8[i] = //Delete the first byte of the first character
                            
said_to_utf8[i+1] = // Delete the second byte of the first character
                            
said_to_utf8[i+2] = 0//...
                            
said_to_utf8[i+3] = 0xEF //The first byte of the character that I want to appear
                            
said_to_utf8[i+4] = 0xBB //The second byte of the character that I want to appear
                            
said_to_utf8[i+5] = 0xBC//the third byte...
                            
said_to_utf8[i+6] = 0//said_to_utf8[i+6] The end of the replaced character should be specified ?
                            
said_to_utf8[i+7] = said_to_utf8[i+7]
                            
said_to_utf8[i+8] = said_to_utf8[i+8]
                            
                            
                        } 
But the result was that the letters that I modified did not appear?
__________________

Last edited by abdobiskra; 07-05-2023 at 18:51.
abdobiskra is offline
Send a message via Skype™ to abdobiskra
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-05-2023 , 19:02   Re: How to check letters and words in sentences?
Reply With Quote #22

Of course you can, but I struggle with understanding how your letters/words work. I don't know what signifies a new word, how letters have a different number of bytes, etc.

I would need a very literal example to provide help.
__________________
Bugsy is offline
abdobiskra
Veteran Member
Join Date: Jul 2014
Location: Algeria
Old 07-06-2023 , 06:11   Re: How to check letters and words in sentences?
Reply With Quote #23

Well in the code I reverse the letters and words from left to right to give clear words.
So the word and its bytes would be:
"سلام" = PEACE (Hello)

It consists of four letters:

0xEF 0xBA 0xB3 // سـ
0xEF 0xBB 0x9F // لـ
0xEF 0xBA 0x8E // ا
0xEF 0xBB 0xA1 // م

I want to delete the bytes in the middle ([0xEF 0xBB 0x9F // لـ ] and [0xEF 0xBA 0x8E // ا ])or replace them with another single character consisting of 3 bytes or a symbol for example consisting of 2 bytes

letter : 0xEF 0xBB 0xBC // ﻼ
symbol : 0xD9 0x80 // ـ
Explanation inside the code on what I did:
PHP Code:
            for (new 0sizeof(said_to_utf8); i++)
            {
                
//the letters in the middle of the word
                
if (&& sizeof(said_to_utf8) && said_to_utf8[1] != ' ' && said_to_utf8[3] != ' ' && said_to_utf8[3] != '\0') {
                    
                    
//Checks the second and third bytes of the first intermediate character (ا) and the third byte of the second intermediate character (لـ
                    
if (said_to_utf8[i+1] == 0xBA && said_to_utf8[i+2] == 0x8E  &&  said_to_utf8[i+5] == 0x9F)
                    {
                                
// Delete The bytes of the first intermediate character (0xEF 0xBA 0x8E // ا)
                            
said_to_utf8[i] = 0
                            said_to_utf8
[i+1] = 
                            said_to_utf8
[i+2] = 0
                            
                            
//Replace the bytes of the second middle character (0xEF 0xBB 0x9F // لـ) with (0xEF 0xBB 0xBC // ﻼ)
                            
said_to_utf8[i+3] = 0xEF
                            said_to_utf8
[i+4] = 0xBB
                            said_to_utf8
[i+5] = 0xBC
                            
//Making sure that the next letter is equal to itself because it has disappeared but it remained hidden!!(0xEF 0xBA 0xB3 // سـ)
                            
said_to_utf8[i+6] = said_to_utf8[i+6]
                            
said_to_utf8[i+7] = said_to_utf8[i+7]
                            
said_to_utf8[i+8] = said_to_utf8[i+8]    
                            
                    }
                }
            } 
P.s: Byte checking is from left to right of the word.
I'm sorry for not explaining in a better way...Tell me if there are any points that are not clear.
__________________

Last edited by abdobiskra; 07-06-2023 at 09:13. Reason: add code
abdobiskra is offline
Send a message via Skype™ to abdobiskra
abdobiskra
Veteran Member
Join Date: Jul 2014
Location: Algeria
Old 07-13-2023 , 06:41   Re: How to check letters and words in sentences?
Reply With Quote #24

Quite simply I just want some way to replace the bytes
Two letters for one letter or one letter for two letters. (by bytes)
Replace two characters that do not have the same number of bytes

btw: The last words in the chat line are disappearing. Seems to be over the limit. How do I fix this?
__________________
abdobiskra is offline
Send a message via Skype™ to abdobiskra
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-13-2023 , 12:09   Re: How to check letters and words in sentences?
Reply With Quote #25

So some characters are 4 bytes while others are 2 or 3? If so, are there any constant rules that allow you to determine this?

If there is, I can write code that will iterate through each letter (of 4, 3 or 2 bytes) and you can do whatever conditions you want based on individual byte values.
__________________

Last edited by Bugsy; 07-13-2023 at 12:10.
Bugsy is offline
abdobiskra
Veteran Member
Join Date: Jul 2014
Location: Algeria
Old 07-13-2023 , 13:05   Re: How to check letters and words in sentences?
Reply With Quote #26

Yes, All the characters I have are 3 bytes. I am thinking of replacing 2 characters (6 bytes) with another character or symbol that is only 2 bytes.
I would like to know how to delete and modify the bytes because what I tried did not give a satisfactory result

Please share it.
__________________
abdobiskra is offline
Send a message via Skype™ to abdobiskra
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-13-2023 , 13:30   Re: How to check letters and words in sentences?
Reply With Quote #27

Are any of the bytes within your multi-byte characters 0/null/EOS? If not, you can use string natives to do all of your copying. If there are nulls intertwined, you need to copy bytes manually.

You need to copy from byte 0 to one characters before the position of the first character to be replaced, insert the new characters, and then append from 1 after the replaced position to the end of your string.

Example, suppose you have: "This is a long string"

I want to replace "long" with "very short"

Copy "This is a " to your destination string
Then append "very short"
Then append " string"
__________________
Bugsy 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 17:02.


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