I’m making a wordgame where I’m pulling in the Scrabble OSPD as a .txt document to check if words exist, yet I’m having trouble with equivalency checking. The dictionary is formatted like this:

aa
aah
aahed
aahing
aahs
aal
aalii
aaliis
aals
aardvark
...

While my code for parsing is this:

var aTemp:String[];    	
var tWordList = Resources.Load("ScrabbleOSPD", typeof(TextAsset))  as TextAsset;
    	
aTemp = tWordList.text.Split("\

"[0]);

With this setup, if I Debug.Log(aTemp[9]), it prints out aardvark to the console. However, when I check if(aTemp[9] == “aardvark”), it always returns False, even when I try other words. Does anyone know why this is happening? I originally thought the newline characters may have not been removed by split, but checking against “aardvark
" and "
aardvark” also both return False.

Try this:

import System.Linq;

var tWordList = Resources.Load("ScrabbleOSPD", typeof(TextAsset))  as TextAsset;
 
var aTemp = tWordList.text.Split("\

"[0]).Select(function(s) s.Trim()).ToList();

if(aTemp.Contains("aardvark"))
{
    //Do something
}

I printed out each character in the word and its corresponding ASCII value:

function Start () 
{
    var tWordList = Resources.Load("ScrabbleOSPD", typeof(TextAsset)) as TextAsset;

    var aTemp : String[] = tWordList.text.Split("

"[0]);

    var word = aTemp[9];

    var message : String = "";
    for(var i = 0; i < word.Length; ++i)
    {
        message += "{" + word _+ " : " + parseInt(word*) + "}, ";*_

}
Debug.Log(message);
}
This is the output I’m getting:
{a : 97}, {a : 97}, {r : 114}, {d : 100}, {v : 118}, {a : 97}, {r : 114}, {k : 107}, {
: 13},
Notice { : 13} at the end? According to the [ASCII table][1], 13 is the code for carriage return (“\r”). You were looking for "
" only, keep in mind that some text editors add "\r
" instead of just "
", for completeness.

Figure a way to split with "\r
", or use aTemp[9] == "aardvark\r" for your comparison:

if(aTemp[9] == “aardvark”)
Debug.Log(“A”);
if(aTemp[9] == “aardvark\r”)
Debug.Log(“B”);
_*[1]: http://www.asciitable.com/*_