Click here to Skip to main content
15,885,038 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
It seems that the delimiter character in the string.split command has to be less the ascii 128. For example, it does not seem to accept characters such as ‡ (135) or ¶ (182).

Is there any way to get VB.Net to accept one of these characters?
Posted
Comments
Sergey Alexandrovich Kryukov 10-Feb-14 20:06pm    
You are just a troublemaker... :-)
—SA

1 solution

You scared me to death. :-)
Well, not quite so; in fact, I first assumed that I rather should not trust you, but… it sounds quite troublesome enough, so I tested it. Of course, what you say turns out to be not true: everything works correctly with any delimiters, including the characters you mentioned in your example. I used .NET versions 3.5 for the test, which is old enough.

You need to take care about your testing skills. :-)

[EDIT]

What you say about File.ReadAllLines is not true. (Again!)
Please, be more careful. Please see my comment below. In general case, you can use another File.ReadAllLines method, with encoding:
http://msdn.microsoft.com/en-us/library/bsy4fhsa%28v=vs.110%29.aspx[^].

But if your problem was '^' (it is not!) it would be irrelevant anyway.

Look, you need to 1) do your work methodically; 2) use the debugger; 3) learn what Unicode is and how it works — write now you don't have a clue.

—SA
 
Share this answer
 
v2
Comments
KevinBrady57 11-Feb-14 17:04pm    
Now I understand the problem I am having more fully. Thank you Sergey.

The problem is not with the split command, but with reading the data from the file. I use the following code to read the entire data file: Dim ostr() As String = File.ReadAllLines(FullFileName). Each array element is one record, such as: 20001^1000^1^4850^E Speedway^^Tucson^1004^85712^^63270. In this case, the record fields are delimited by the "^" character. I have a method that will populate the correct fields by splitting this record based on the specified character. The mentioned vb.net function to read the entire data file does not "recognize" the delimiter character if it is greater than ascii 127. Is there a way to get the File.ReadAllLines(FullFileName) function to recognize extended ascii characters?
Sergey Alexandrovich Kryukov 11-Feb-14 18:20pm    
Forget "extended ASCII characters"! They are not supported anywhere, and even when they were used, it wasn't in any standard. Embrace Unicode and try to understand how it works. No, Unicode is not encoding (but UTFs are). No, Unicode is not 16-bit code for characters. And so on...

Now, '^' was always in ASCII, is nothing special. What you say is not true. File.ReadAllLines reads everything into the Unicode string, but the result depends on what encoding the actual file used.

—SA
KevinBrady57 11-Feb-14 18:47pm    
If I replaced the "^" character with a "‡", File.ReadAllLine does not recognize at and it cannot be split.
Sergey Alexandrovich Kryukov 11-Feb-14 19:46pm    
Sigh...
ReadAllLines does not have to recognize anything, it just reads all the lines.
Did you start to use the debugger. If not, please refrain from following post until you do and test everything.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900