-
1 Attachment(s)
some characters displayed weirdly
i am reading a .txt file line by line.. adding each line in a listbox... but some characters do not show well in the listbox...
e.g.
in .txt file:
97 Jankulovski
98 Galásek
99 Poborský
100 Plasil
101 Rosický
but in listbox [see attachment]
i even used the forms 2.0 controls but still no good
btw: the .txt file i am reading is in UTF-8 ... when i convert to unicode..nothing shows up in vb... and when i convert it to ANSI... the accents are okay but some additional characters show up like "?????" or black boxes characters
-
Re: some characters displayed weirdly
Textboxes and listboxes don't like unicode characters. I am sure someone here will have a unicode-friendly alternative for you :-)
As an alternative, you could pre-filter the data and take out the unicode ones (replacing them with similar letters or something)
-
Re: some characters displayed weirdly
Have you tried changing the font name used by the listbox?
-
Re: some characters displayed weirdly
-
Re: some characters displayed weirdly
Quote:
Originally Posted by leinad31
Have you tried changing the font name used by the listbox?
i have tried ... the weird chars are still there!!!
how can i pre-filter the data and take out the unicode ones???
-
Re: some characters displayed weirdly
Basically you use the replace() command to replace specific characters with more friendly characters...so you need to work out the characters you want to take out and what to replace them with :-)
-
Re: some characters displayed weirdly
Funny, works fine for me.
-
1 Attachment(s)
Re: some characters displayed weirdly
Quote:
Originally Posted by smUX
Basically you use the replace() command to replace specific characters with more friendly characters...so you need to work out the characters you want to take out and what to replace them with :-)
the problem for me is that the .txt file contain the names of football players and there are about 3200 players!!!! it will be hard to find out all the weird characters to remove!!!
edit: i have attached the text file.... there are square characters too.. the list is generated from a football game database....
-
Re: some characters displayed weirdly
What version of VB are you using? Those chars works fine with me. No problem at all.
-edit-
On second thought, the font you're using... have you tried the suggestion of leinad?
Change your font to the default and see what happens.
-
Re: some characters displayed weirdly
i am on vb 6.0
edit: and thanks for these quick replies!!! :)
-
Re: some characters displayed weirdly
Quote:
Originally Posted by lplover2k
the problem for me is that the .txt file contain the names of football players and there are about 3200 players!!!! it will be hard to find out all the weird characters to remove!!!
Doesn't matter how many players there are, there should be a limit to how many unique characters there are for you to replace. However, my suggestion is to try to find a better way to display them rather than filtering now...someone here must know a way to display non-standard characters in a listbox...have you tried using a listview or maybe a custom listbox designed with the intention of displaying non-standard characters, there MUST be one out there and someone'll link you to it :-)
I'd play about with it myself if I had VB installed...I recently reinstalled windows though and haven't got around to installing VB yet :-)
-
1 Attachment(s)
Re: some characters displayed weirdly
i have tried UniListBox but the weird chars are still there! will try to replace the characters not well displayed...
edit:
ey tried to replace 1 accents look
in the text file it's
21 Säumel
i used the code
Code:
item=replace(str,"ä","a")
where str is the line (21 Säumel ) in my text file
and then add item to my list but result the same as before see attachment
-
Re: some characters displayed weirdly
You said earlier that the file is UTF-8...you tried converting to unicode then displaying in the UniListBox?
You might have to look into actually prefiltering (like I said before) and converting characters to valid unicode characters for it to display properly. It's not a problem I've had as I don't work with unicode data often and when I do it's not required that I display it in any way, so I am little or no use to you :-)
Edit: A tip for you...have a textbox on your form and have the name output to that textbox...then manually copy the 2 characters and use THAT in your manual replace...that should work fine :-)
Maybe make it so on mousedown on the listbox it puts that line into the textbox?
-
Re: some characters displayed weirdly
Quote:
Originally Posted by smUX
You said earlier that the file is UTF-8...you tried converting to unicode then displaying in the UniListBox?
You might have to look into actually prefiltering (like I said before) and converting characters to valid unicode characters for it to display properly. It's not a problem I've had as I don't work with unicode data often and when I do it's not required that I display it in any way, so I am little or no use to you :-)
Edit: A tip for you...have a textbox on your form and have the name output to that textbox...then manually copy the 2 characters and use THAT in your manual replace...that should work fine :-)
Maybe make it so on mousedown on the listbox it puts that line into the textbox?
lol isn't there a less time consuming solution?? i am desperate :(
-
Re: some characters displayed weirdly
There probably is a better way to do it, but it's your call whether you wait or not :-P
-
Re: some characters displayed weirdly
Quote:
Originally Posted by lplover2k
... i am desperate :(
It doesn't look according to your comments about some solutions :ehh:
Try this...
... or Merri's UniListBox ;)
-
Re: some characters displayed weirdly
Quote:
Originally Posted by gavio
It doesn't look according to your comments about some solutions :ehh:
Try
this...
... or Merri's
UniListBox ;)
already tried both solution!!!
somebody....plz try the .txt file i attached.... maybe something's wrong with the .txt file...
-
Re: some characters displayed weirdly
ok i have decided to manually remove all the weird characters.... removed most of them but if there's a better solution.. plz post :) and thx for ur help
-
Re: some characters displayed weirdly
The unorthodox methods (the ones I usually suggest and the ones that are for people who know of no orthodox methods :-)) are usually the best ones to go for...they do the job, albeit a weird way and possibly with extra work
-
Re: some characters displayed weirdly
Quote:
Originally Posted by smUX
The unorthodox methods (the ones I usually suggest and the ones that are for people who know of no orthodox methods :-)) are usually the best ones to go for...they do the job, albeit a weird way and possibly with extra work
yeah thanks but it takes lil more time for my listbox to fill up now... i have managed to filter almost all weird characters
-
Re: some characters displayed weirdly
some of the strings are not valid characters even in the text file
check lines 366 and 234
-
Re: some characters displayed weirdly
some of the strings are not valid characters even in the text file
check lines 366 and 234
an option
save the textfile as ansi, then just remove the question marks
-
Re: some characters displayed weirdly
Does the actual data being loaded change regularly? If you use the same data, you might find it easier to filter and save it in word or something then load it already filtered into your listbox.
Does it even HAVE to be a listbox...if you're just displaying the info, you might find a richtextbox would work better :-)
-
Re: some characters displayed weirdly
Quote:
Originally Posted by westconn1
some of the strings are not valid characters even in the text file
check lines 366 and 234
an option
save the textfile as ansi, then just remove the question marks
That's a bad idea. Then any line with an "ä", for example, will turn into a bunch of question marks(just like every other foreign character would), and he won't know what to replace it with. All changes to any foreign characters should be assigned with a specific character 1-by-1, character-by-character. Otherwise you're screwed.
-
Re: some characters displayed weirdly
Quote:
Originally Posted by BrendanDavis
All changes to any foreign characters should be assigned with a specific character 1-by-1, character-by-character.
Not quite 1 by 1...if it *is* unicode or something similar you will probably find it's 2 by 1 (as the characters are stored using 2 bytes rather than 1) :-)