I tried removing the Unicode Whitespaces in the string using words[len].Trim()
but still there's still an extra character.
Every letter represents the coordinate of where the letter is. As you can see there's an extra coordinate/value and it is always located at the end of the string. (dont mind the '# tries') Can you help me Identify what is the extra invisible unicode and what to do in order for it to be removed?
private string[] FisherShuffle(string[] words) {
int len = words.Length;
while(len > 0) {
float index = Mathf.Floor(Random.Range(0f, 1f) * len);
len--;
var temp = words[len].Trim();
words[len] = words[(int)index];
words[(int)index] = temp;
}
return words;
}
UPDATE:
I have found out that the ASCII value is 13. I also have tried using TrimEnd('\n','\n')
& words[len].TrimEnd(System.Environment.NewLine.ToCharArray())
to no avail
private string[] FisherShuffle(string[] words) {
int len = words.Length;
int index;
string temp;
while(len > 0) {
index = (int) Mathf.Floor(Random.Range(0f, len));
len--;
//temp = words[len].TrimEnd('\n','\r');
temp = words[len].TrimEnd(System.Environment.NewLine.ToCharArray());
words[len] = words[index];
words[index] = temp;
}
return words;
}
float index = Mathf.Floor(Random.Range(0f, 1f) * len)
and later casting to int, you could just writeint index = Random.Range(0, len)
\$\endgroup\$TrimEnd('\r','\n')
but to no avail. \$\endgroup\$