Do not use on any
shared computer
July 25, 2008 02:34pm pdt
null
[x]
Attachment Details

how to replace strange macintosh characters with a different character

Tags: VB.NET 2.0 ASP.NET 2.0
I have a tab-delimited file that came from a Mac OS-X program with a *.DAT extension.
I have no problem reading it into a windows app I am writing except for one small issue:
It carries over some characters that I have no idea what the correct character code is in order to remove it.  Some text has bullets in it and I thought they were ASCII CHR(165) as I've seen in smoe other posts, but that is not the case even though they show up as the Yen symbol when opened in WordPad, but show up as squares in everything else.  Doing research, the Yen symbol is indeed ASCII 165.
There must be another yen symbol somewhere in Unicode space OR the VB.NET 2.0 string type is not actually Unicode OR the REPLACE function does not recognize Unicode.
I've tried every possible combination of replace I can think of:
Microsoft.VisualBasic.Replace(mystring, CHRW(165), "*")
Microsoft.VisualBasic.Replace(mystring, CHR(165), "*")
Microsoft.VisualBasic.Replace(mystring, "¥", "*")
mystring.Replace("¥", "*")
mystring.Replace(CHR(165), "*")  
mystring.Replace(CHRW(165),"*")
with no luck.
To make sure the functions were working, I put in a common letter and tested it, and it worked just fine.
The file is Tab-delimited format and opens fine in Excel 2003 without importing with a *.DAT extension.
The Yen symbol is just one of the many codes I cannot determine even though every reference claims it is ASCII 165 or Unicode 00A5.
I'd prefer to simply delete all the characters, but some, I can tell are bullets or superscripts and others that do not agree with Windows codesets.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
Dim coldelim As String = vbTab
        Try
            Dim filestream As StreamReader = File.OpenText(localfilepath)
            Do Until filestream.EndOfStream
                Dim line As String = Microsoft.VisualBasic.Replace(filestream.ReadLine, ChrW(165), "*", , , CompareMethod.Binary)
                Dim ARYfield As Array = line.Split(coldelim)
                Dim row As DataRow = dt.NewRow()
                For i As Integer = 0 To UBound(ARYfield)
                    If IsDBNull(ARYfield(i)) Then
                        row(i) = String.Empty
                    Else
                        row(i) = CType(ARYfield(i), String)
                    End If
                Next
                dt.Rows.Add(row)
            Loop
            filestream.Close()
            success = True
        Catch ex As Exception
            success = False
        End Try
Start your free trial to view this solution
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Question Stats
Zone: Programming
Question Asked By: bd9000
Solution Provided By: bd9000
Participating Experts: 2
Solution Grade: A
Views: 23
Translate:
Loading Advertisement...
 
[+][-]Expert Comment by CSLEEDS
Expert Comment by CSLEEDS:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Expert Comment by jaime_olivares

Rank: Wizard

Expert Comment by jaime_olivares:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by bd9000
Author Comment by bd9000:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by bd9000
Author Comment by bd9000:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by bd9000
Author Comment by bd9000:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by bd9000
Author Comment by bd9000:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by bd9000
Author Comment by bd9000:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Accepted Solution by bd9000
Accepted Solution by bd9000:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080723-EE-VQP-34 / EE_QW_2_20070628