Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading in special characters from notepad--such as bullets & TM

Status
Not open for further replies.

Beast96GT

Programmer
Jul 18, 2007
5
US

I'm at wit's end, guys. I can't find anything in these forums or on Google that can help me.

I'm simply trying to read in a simple notepad ASCII text file that has the TradeMark Symbol and the bullet symbol. No matter what I do, they're always read in as a combination of <quotation>X where X is another character.

I've tried multiple ways of reading them in and always get the same result. I need to be able to read in ONE character at a time because this is a tokenizer program. I've tried the following:

Open file for Input as #1
char = Input(1, #1)

Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile(File, 1, TristateTrue)
''and I've also tried TristateFalse
f.Read(1)

A Trademark symbol Chr(153) ALWAYS reads in as two characters--"!
And a bullet always reads in as "X where X is a space.

I thought this might be a unicode issue, even though the file is ASCII so I tried reading it in as Unicode, but NO lock. I can't simply convert it everytime I run into an "<space> because I have those all over the place for other reasons.

Any help or if you need clarification on my problem is MUCH MUCH appreciated.

Chris
 




Hi,

In what application are you seeing these characters DISPLAYED?

What CharacterSet or FONT are you using to display?

Skip,

[glasses] To be safe on the [red]FOURTH[/red],
Don't take a [red]FIFTH[/red] on the [red]THIRD[/red]
Or you might not come [red]FORTH[/red] on the [red]FIFTH[/red]
[red][highlight blue]FORTH[/highlight][/red][white][highlight red]WITH[/highlight][/white] [tongue]
 

I'm using the default font in Excel, and watching the variables as I load them in, in the IDE. I then load them in cells and it confirms my suspicions.

Do you think that the current font does not support the characters and is having difficulty loading them in?

Chris
 




Not all fonts have what you might need.

Skip,

[glasses] To be safe on the [red]FOURTH[/red],
Don't take a [red]FIFTH[/red] on the [red]THIRD[/red]
Or you might not come [red]FORTH[/red] on the [red]FIFTH[/red]
[red][highlight blue]FORTH[/highlight][/red][white][highlight red]WITH[/highlight][/white] [tongue]
 
What happens if you open the file with NotePad ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
It opens fine and displays the "TM" and the bullet inside of notepad.

How do I change the font for the entire sheet?

I tried ActiveSheet.Font.Name = "Tahoma", but it errors out on me.

Forgive me for being a noob at this, but I'm a C++ programmer trying to write an excel app for the project. Let's just say that VBE is no Visual Studio! :)

Is there a way to make it show what the member of an object are when you hit '.'?

Chris
 
When in the VBE feel free to play with the F2 (and obviously the F1) keys.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
You could try opening the file like a normal file and then looking at each character after the file is open
 

Fr33dan,

That's what I do. Every single character is fine, except for the special ones.

I've tried changing to the notepad font that is being used:
Application.StandardFont = "Lucida Console"

No go.

Now I'm trying encoding and charactersets...
 
From what you said in your original post your using OpenTextFile. what I mean was use workbooks.open to open the file and then loop through one at a time that way
Code:
i = 1
while not isEmpty(cells(i,1))
   for c = 1 to len(cells(i,1))
      character = left(right(cells(i,1),i),1)
      ..Do whatever you need to do
   next c
wend
 
ops posted to quickly and left out some code
Code:
workbooks.open(FILENAME)
i = 1
while not isEmpty(cells(i,1))
   for c = 1 to len(cells(i,1))
      character = left(right(cells(i,1),i),1)
      ..Do whatever you need to do
   next c
   i = i + 1
wend
 
Thanks for the help... It turns out the problem was I'm in fact dealing with a Unicode file. My parter sent it over to me and told me that it's an ASCII file FOR SURE, and NOT Unicode. That's what I get for listening to him.

VBA was converting all the normal characters to standard ASCII, but having problems with the extended codes.

Seems the 2-byte unicode entry for a bullet, divided up is a <quotation> and a <space>. Hex 22 and 20 when it should have been unicode 2220.

Thanks again, and I apologize for time waster. :)

Peace.

Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top