# \[Solved\] Comparing two text variables issue!

**URL:** <https://community.thunkable.com/t/solved-comparing-two-text-variables-issue/415057>\
**Category:** Questions about Thunkable X\
**Tags:** solved\
**Created:** [January 18, 2020, 4:37pm UTC](https://community.thunkable.com/t/solved-comparing-two-text-variables-issue/415057 "2020-01-18T16:37:35Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidsobhysabetb](https://avatars.discourse-cdn.com/v4/letter/d/ce73a5/32.png) [@davidsobhysabetb](https://community.thunkable.com/u/davidsobhysabetb)\
**Post date:** [January 18, 2020, 4:37pm UTC](https://community.thunkable.com/t/solved-comparing-two-text-variables-issue/415057/1 "2020-01-18T16:37:35Z")

</div>

Hi,  
I’m trying to do a very simple task, Speech Recognizer block would be used to identify a word , I’m saving the output of the block and comparing it with another variable has the matched word  
the problem is that everything goes well if and only if language is English else or i will be more clear when making language to Arabic the comparison of two really matched variables is set to FALSE !!  
i made a debug label to see if the output is really the same word and found that it’s really the same word but comparison result still false !  
how to solve this problem ??  
Thanks in advance.

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [January 18, 2020, 5:06pm UTC](https://community.thunkable.com/t/solved-comparing-two-text-variables-issue/415057/2 "2020-01-18T17:06:41Z")

</div>

Hello!

Can you share a screenshot of you’re blocks you are using to accomplish the task?

---

<div class="post-metadata">

**Author:** ![davidsobhysabetb](https://avatars.discourse-cdn.com/v4/letter/d/ce73a5/32.png) [@davidsobhysabetb](https://community.thunkable.com/u/davidsobhysabetb)\
**Post date:** [January 19, 2020, 12:11am UTC](https://community.thunkable.com/t/solved-comparing-two-text-variables-issue/415057/3 "2020-01-19T00:11:15Z")

</div>

![index5](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/e/b/eb585c0b6f05de0dacb659555b1eea4b948ba2ae.jpeg)

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [January 19, 2020, 5:35am UTC](https://community.thunkable.com/t/solved-comparing-two-text-variables-issue/415057/4 "2020-01-19T05:35:31Z")

</div>

It’s hard to tell because we can’t see your other blocks but here’s a question for you:

Are you meaning to compare _stored VoiceLanguage_ with _app Voice_? Or are you supposed to be comparing _app VoiceInput_ with _app Voice_?

And what do you have stored in _app Voice_?

---

<div class="post-metadata">

**Author:** ![davidsobhysabetb](https://avatars.discourse-cdn.com/v4/letter/d/ce73a5/32.png) [@davidsobhysabetb](https://community.thunkable.com/u/davidsobhysabetb)\
**Post date:** [January 19, 2020, 9:50am UTC](https://community.thunkable.com/t/solved-comparing-two-text-variables-issue/415057/5 "2020-01-19T09:50:55Z")

</div>

Yes , the purpose is to compare the two variables.  
VoiceInput is the spoken word  
and app Voice is the word I’m comparing with  
example1:  
stored VoiceLanguage = ENGLISH  
app Voice = “Hello”  
app VoiceInput = “Hello”  
Result or TestLabel = True

example2:  
stored VoiceLanguage = ARABIC  
app Voice = “تشغيل” ( Arabic Word )  
app VoiceInput = “تشغيل” ( The same Arabic Word )  
Result :

I added the debugging Text input to fill with the spoken word and the strange thing is that the word is 100% the same app voice word !

---

<div class="post-metadata">

**Author:** ![davidsobhysabetb](https://avatars.discourse-cdn.com/v4/letter/d/ce73a5/32.png) [@davidsobhysabetb](https://community.thunkable.com/u/davidsobhysabetb)\
**Post date:** [January 19, 2020, 9:52am UTC](https://community.thunkable.com/t/solved-comparing-two-text-variables-issue/415057/6 "2020-01-19T09:52:47Z")

</div>

I noticed that Text block trim spaces doesn’t work in Arabic words too !

---

<div class="post-metadata">

**Author:** ![davidsobhysabetb](https://avatars.discourse-cdn.com/v4/letter/d/ce73a5/32.png) [@davidsobhysabetb](https://community.thunkable.com/u/davidsobhysabetb)\
**Post date:** [January 19, 2020, 10:58am UTC](https://community.thunkable.com/t/solved-comparing-two-text-variables-issue/415057/7 "2020-01-19T10:58:38Z")

</div>

I noticed that the output of Speech Recognizer when language is ARABIC , length is increased by one !  
so, if i got the length of a known text the result is correct , but when getting the length of the output of speech recognizer for the same known text the result is NOT the same !!

![index5](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/5/45bb8259eead69224b7fd95eebba55c8a21ef0c6.jpeg)

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [January 19, 2020, 1:07pm UTC](https://community.thunkable.com/t/solved-comparing-two-text-variables-issue/415057/8 "2020-01-19T13:07:07Z")

</div>

I believe this has been addressed in another post. Please search the forum before posting a new topic.

> [@Help me with speech recognizer blocks](http://community.thunkable.com/t/help-me-with-speech-recognizer-blocks/403985/11):
>
> Hey @12345671 here’s a quick tutorial that explains the blocks and a sample project that you can remix yourself to use as a reference: Remix link: [https://x.thunkable.com/copy/6af8e957c14b551c188fa84e191431d3](https://x.thunkable.com/copy/6af8e957c14b551c188fa84e191431d3)

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [January 19, 2020, 3:55pm UTC](https://community.thunkable.com/t/solved-comparing-two-text-variables-issue/415057/9 "2020-01-19T15:55:11Z")

</div>

Your blocks are not correct. You need to check if app VoiceInput = app Voice.

---

<div class="post-metadata">

**Author:** ![davidsobhysabetb](https://avatars.discourse-cdn.com/v4/letter/d/ce73a5/32.png) [@davidsobhysabetb](https://community.thunkable.com/u/davidsobhysabetb)\
**Post date:** [January 19, 2020, 8:26pm UTC](https://community.thunkable.com/t/solved-comparing-two-text-variables-issue/415057/10 "2020-01-19T20:26:49Z")

</div>

Sorry , but this issue is completely different !

---

<div class="post-metadata">

**Author:** ![davidsobhysabetb](https://avatars.discourse-cdn.com/v4/letter/d/ce73a5/32.png) [@davidsobhysabetb](https://community.thunkable.com/u/davidsobhysabetb)\
**Post date:** [January 19, 2020, 8:29pm UTC](https://community.thunkable.com/t/solved-comparing-two-text-variables-issue/415057/11 "2020-01-19T20:29:35Z")

</div>

Oh ! that’s really a screenshot mistake i noticed this before but forgot to repost the screenshot my bad sorry .  
but the problem still exist as i said before length of text is really increased by one !  
notice that the problem occurs only in Arabic , in English there’s no problem !

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [January 19, 2020, 8:37pm UTC](https://community.thunkable.com/t/solved-comparing-two-text-variables-issue/415057/12 "2020-01-19T20:37:59Z")

</div>

It’s not a great solution but, if you know it’s always going to have an extra space on either side of the word, you could use a “text” command block to remove the space. I think that may work. It doesn’t solve the answer of why though.

---

<div class="post-metadata">

**Author:** ![davidsobhysabetb](https://avatars.discourse-cdn.com/v4/letter/d/ce73a5/32.png) [@davidsobhysabetb](https://community.thunkable.com/u/davidsobhysabetb)\
**Post date:** [January 19, 2020, 8:48pm UTC](https://community.thunkable.com/t/solved-comparing-two-text-variables-issue/415057/13 "2020-01-19T20:48:09Z")

</div>

Actually as i said before, trimming spaces doesn’t worke also in Arabic text !

---

<div class="post-metadata">

**Author:** ![davidsobhysabetb](https://avatars.discourse-cdn.com/v4/letter/d/ce73a5/32.png) [@davidsobhysabetb](https://community.thunkable.com/u/davidsobhysabetb)\
**Post date:** [January 19, 2020, 8:52pm UTC](https://community.thunkable.com/t/solved-comparing-two-text-variables-issue/415057/14 "2020-01-19T20:52:58Z")

</div>

I solved the problem by :  
1- getting the length of spoken text  
2- make the new length = length - 1  
3- compare using ( is Text contains of word && length == length of word )

It solved my problem but didn’t make me understand why that happened !!

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [January 19, 2020, 9:26pm UTC](https://community.thunkable.com/t/solved-comparing-two-text-variables-issue/415057/15 "2020-01-19T21:26:29Z")

</div>

What I would do is to join the text you are receiving from the voice recognition with two symbol characters so that you can see what is being added. For example, Set label text to join # + VoiceInput + #. That way, when you look at the label, you will see something like #Hello # and you’ll know that it’s adding a space to the end of the variable.

---

<div class="post-metadata">

**Author:** ![davidsobhysabetb](https://avatars.discourse-cdn.com/v4/letter/d/ce73a5/32.png) [@davidsobhysabetb](https://community.thunkable.com/u/davidsobhysabetb)\
**Post date:** [January 19, 2020, 9:31pm UTC](https://community.thunkable.com/t/solved-comparing-two-text-variables-issue/415057/16 "2020-01-19T21:31:09Z")

</div>

I added the text to input text and copied it to see if it’s changed the result is the word is 100% the same with no any extra characters and that’s the strangest thing !!

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [January 19, 2020, 10:12pm UTC](https://community.thunkable.com/t/solved-comparing-two-text-variables-issue/415057/17 "2020-01-19T22:12:52Z")

</div>

That is strange! Without seeing your blocks, it’s hard to know why that might be happening. Perhaps it’s just a bug with Arabic language processing?

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [January 20, 2020, 4:30am UTC](https://community.thunkable.com/t/solved-comparing-two-text-variables-issue/415057/18 "2020-01-20T04:30:57Z")

</div>

This project is available at [Thunkable](https://x.thunkable.com/copy/0ca5797e36776086d4bc68c7b577a1c0)

I submitted a bug report at [Arabic speech recognition returns incorrect string length · Issue #336 · thunkable/thunkable-issues · GitHub](https://github.com/thunkable/thunkable-issues/issues/336).

I was able to duplicate the problem you described. I had the speech recognition recognize شكرا لكم (_shukraan lakum_; _thank you_ in English) and check the word length of the recognized word vs. the stored variable value شكرا لكم.

The length of the stored variable was 8 while the length of the recognized speech was 9.

So yeah, this doesn’t help you but at least duplicating it suggests there may be a bug or something for someone else to discover what is causing this.

![IMG_8737](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/c/acf7faf86d75d2d44d74cb6748aad7e4096c8aa4.jpeg)

 ![Screen Shot 2020-01-19 at 8.34.18 PM copy 3](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/3/c3e55277c8b73a68120d8b0a3a184bd259c64361.jpeg)

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [January 20, 2020, 5:26am UTC](https://community.thunkable.com/t/solved-comparing-two-text-variables-issue/415057/19 "2020-01-20T05:26:42Z")

</div>

Something else interesting is that when I compare the two text strings character by character, NONE of the characters are equal in the same location in both strings.

The following code returns ≠≠≠≠≠≠≠≠≠

 ![Screen Shot 2020-01-19 at 9.16.07 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/6/260e85257557964f5e838b354c250d82490c1adc.png)

Note that testing speech recognition from French to English results in equal length strings of 7 characters (Bonjour = Bonjour) and the code above returns =======

This might be relevant:

> <https://stackoverflow.com/questions/45858510/swift-string-characters-count-returns-wrong-number-for-an-arabic-string>

And [this](https://stackoverflow.com/a/39045270) about UTF character counting.

Also, the section starting with “Extreme Grapheme Clusters” [here](https://docs.swift.org/swift-book/LanguageGuide/StringsAndCharacters.html#ID293).

---

<div class="post-metadata">

**Author:** ![davidsobhysabetb](https://avatars.discourse-cdn.com/v4/letter/d/ce73a5/32.png) [@davidsobhysabetb](https://community.thunkable.com/u/davidsobhysabetb)\
**Post date:** [January 20, 2020, 12:41pm UTC](https://community.thunkable.com/t/solved-comparing-two-text-variables-issue/415057/20 "2020-01-20T12:41:03Z")

</div>

Thanks a lot for your efforts @tatiang  
Trimming spaces text block doesn’t work also in Arabic words .

[Next page](https://community.thunkable.com/t/solved-comparing-two-text-variables-issue/415057.md?page=2)
