Results 1 to 25 of 25

Thread: some characters displayed weirdly

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    128

    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
    Attached Images Attached Images  

  2. #2
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    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)
    Well, everyone else has been doing it :-)
    Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
    Expect more to come in future
    If I have helped you, RATE ME! :-)

    I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!

    And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.

  3. #3
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: some characters displayed weirdly

    Have you tried changing the font name used by the listbox?

  4. #4
    Frenzied Member zynder's Avatar
    Join Date
    Nov 2006
    Location
    localhost
    Posts
    1,434

    Re: some characters displayed weirdly

    Works with me.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    128

    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???

  6. #6
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    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 :-)
    Well, everyone else has been doing it :-)
    Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
    Expect more to come in future
    If I have helped you, RATE ME! :-)

    I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!

    And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.

  7. #7
    Hyperactive Member BrendanDavis's Avatar
    Join Date
    Oct 2006
    Location
    Florida
    Posts
    492

    Re: some characters displayed weirdly

    Funny, works fine for me.

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    128

    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....
    Attached Files Attached Files
    Last edited by lplover2k; Jan 6th, 2007 at 03:46 PM.

  9. #9
    Frenzied Member zynder's Avatar
    Join Date
    Nov 2006
    Location
    localhost
    Posts
    1,434

    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.
    Last edited by zynder; Jan 6th, 2007 at 03:53 PM.

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    128

    Re: some characters displayed weirdly

    i am on vb 6.0

    edit: and thanks for these quick replies!!!

  11. #11
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    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 :-)
    Well, everyone else has been doing it :-)
    Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
    Expect more to come in future
    If I have helped you, RATE ME! :-)

    I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!

    And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    128

    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
    Attached Images Attached Images  
    Last edited by lplover2k; Jan 6th, 2007 at 05:51 PM.

  13. #13
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    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?
    Well, everyone else has been doing it :-)
    Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
    Expect more to come in future
    If I have helped you, RATE ME! :-)

    I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!

    And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.

  14. #14

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    128

    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

  15. #15
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    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
    Well, everyone else has been doing it :-)
    Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
    Expect more to come in future
    If I have helped you, RATE ME! :-)

    I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!

    And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.

  16. #16
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: some characters displayed weirdly

    Quote Originally Posted by lplover2k
    ... i am desperate
    It doesn't look according to your comments about some solutions

    Try this...

    ... or Merri's UniListBox

  17. #17

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    128

    Re: some characters displayed weirdly

    Quote Originally Posted by gavio
    It doesn't look according to your comments about some solutions

    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...
    Last edited by lplover2k; Jan 7th, 2007 at 02:13 AM.

  18. #18

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    128

    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

  19. #19
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    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
    Well, everyone else has been doing it :-)
    Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
    Expect more to come in future
    If I have helped you, RATE ME! :-)

    I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!

    And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.

  20. #20

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    128

    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

  21. #21
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: some characters displayed weirdly

    some of the strings are not valid characters even in the text file
    check lines 366 and 234
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  22. #22
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  23. #23
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    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 :-)
    Well, everyone else has been doing it :-)
    Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
    Expect more to come in future
    If I have helped you, RATE ME! :-)

    I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!

    And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.

  24. #24
    Hyperactive Member BrendanDavis's Avatar
    Join Date
    Oct 2006
    Location
    Florida
    Posts
    492

    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.

  25. #25
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    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) :-)
    Well, everyone else has been doing it :-)
    Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
    Expect more to come in future
    If I have helped you, RATE ME! :-)

    I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!

    And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width