- Home /
String.Split("¦"[0]) is not finding character
I know it is the "¦" character because I did a search and replace on it with the "|" character in my test file and the Split() worked. Unfortunately I am using a live data feed and cannot replace the character in the feed.
Anyone know how to check for the "¦" character?
If you want to get the string split before the ¦ character, you should be using
String.Split('¦')[0]
Which will get the first string in the returned array. As far as the data feed, I think we would need more information on how you're using the data to help.
Answer by Eric5h5 · Sep 15, 2013 at 11:11 PM
You check for it as normal...this works fine:
function Start () {
var str = "abc¦def¦ghi";
var strs = str.Split("¦"[0]);
for (s in strs) Debug.Log (s);
}
What you wrote here does work. I copied and pasted a line from my data stream into your source and it worked also. The problem then must be isolated down to reading the string from a text file.
The character is in the extended ASCII set if that makes a difference. I am using JavaScript. If this were C I would guess it was an unsigned vs signed char issue. I am baffled here.
No, what text encoding does it use? I know it's a text file. .NET/$$anonymous$$ono uses Unicode for strings, specifically UTF-16.
It is just one byte per character. I believe that is UTF-8.