Recent

Author Topic: hyphen turns to question mark  (Read 9405 times)

SillyOldDragon

  • New Member
  • *
  • Posts: 17
hyphen turns to question mark
« on: October 26, 2014, 03:10:05 am »
When reading from a text file that has hyphens in it and then stuff the text into a stringGrid everything is perfect in both columns except all of the hyphens turn to question marks.

Using Windows 7.  Nothing else weird.

Any ideas?

Thank you - Justine

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: hyphen turns to question mark
« Reply #1 on: October 26, 2014, 03:44:21 am »
My guess, your text file is Ansi encoded, while the grid needs UTF8. Use Utf8Encode

SillyOldDragon

  • New Member
  • *
  • Posts: 17
Re: hyphen turns to question mark
« Reply #2 on: October 26, 2014, 06:34:44 am »
Well, I think it's silly but it worked like a charm.  I now have hyphens in my StringGrid.

Thank you very much.

eny

  • Hero Member
  • *****
  • Posts: 1634
Re: hyphen turns to question mark
« Reply #3 on: October 26, 2014, 08:16:25 am »
Using Windows 7.  Nothing else weird.
That hyphen is probably not actually a hyphen (ascii 45) but some kind of ansi character that also looks like a hyphen.
For example text editors like Word do this.  So if you copy from there and paste into a textfile, you get this situation.
Also if the textfile is created from reading a database that is populated by end users, they might have copied/pasted 'special characters'  into text fields.
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: hyphen turns to question mark
« Reply #4 on: October 26, 2014, 02:56:17 pm »
That hyphen is probably not actually a hyphen (ascii 45) but some kind of ansi character that also looks like a hyphen.
It is a hyphen, actually a "soft hyphen".

eny

  • Hero Member
  • *****
  • Posts: 1634
Re: hyphen turns to question mark
« Reply #5 on: October 26, 2014, 08:45:02 pm »
actually a "soft hyphen".
As I said it's not a hyphen.
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: hyphen turns to question mark
« Reply #6 on: October 26, 2014, 08:57:39 pm »
actually a "soft hyphen".
As I said it's not a hyphen.
What do you mean when you say "not a hyphen"?

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1260
Re: hyphen turns to question mark
« Reply #7 on: October 27, 2014, 10:40:52 am »
What do you mean when you say "not a hyphen"?

This was already explained.
 
That hyphen is probably not actually a hyphen (ascii 45) but some kind of ansi character that also looks like a hyphen.
Lazarus Trunk/FPC Trunk on Windows [7, 10]
  Have you tried searching this forum or the wiki?:   http://wiki.lazarus.freepascal.org/Alternative_Main_Page
  BOOKS! (Free and otherwise): http://wiki.lazarus.freepascal.org/Pascal_and_Lazarus_Books_and_Magazines

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: hyphen turns to question mark
« Reply #8 on: October 27, 2014, 04:04:51 pm »
This was already explained.
 
That hyphen is probably not actually a hyphen (ascii 45) but some kind of ansi character that also looks like a hyphen.
Thank you Mike  :) .
I-1- What are the reason(s) that would prevent you from considering soft hyphen a hyphen?
II-2- Isn't ASCII 45 (XLV) used for minus character (-) as well? Wouldn't that be a reason to have a separate character for hyphen?

Please notice that I'm totally unbiased when it comes to hyphens. I do not endorse Microsoft's position on hyphens, not in their Word product nor in any other product.


Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1260
Re: hyphen turns to question mark
« Reply #9 on: October 27, 2014, 04:18:33 pm »
:-)   First time I've seen the ASCII table in Roman Numerals.  I like that :-)

I suspect @Eny was simply explaining why "-" was appearing as a question mark.  If the character in question wasn't our XLV, the suspicion was that it was a unicode character that just happened to look like XLV when correctly decoded.  Which in fact, turned out to be the case.

I don't think any judgement over whether anything is or isn't a hyphen was intended.   

But on the offchance it was, I'm ducking out now :-)
Lazarus Trunk/FPC Trunk on Windows [7, 10]
  Have you tried searching this forum or the wiki?:   http://wiki.lazarus.freepascal.org/Alternative_Main_Page
  BOOKS! (Free and otherwise): http://wiki.lazarus.freepascal.org/Pascal_and_Lazarus_Books_and_Magazines

eny

  • Hero Member
  • *****
  • Posts: 1634
Re: hyphen turns to question mark
« Reply #10 on: October 27, 2014, 05:10:45 pm »
No reason to duck MC  :D
I'm happy someone actually made an effort to understand my explanation, without taking it out of (the) context (of the thread).
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: hyphen turns to question mark
« Reply #11 on: October 27, 2014, 05:54:41 pm »
I apologize for taking your explanation out of (the) context (of the thread), twisting the meanings of your words, and putting my words in your mouth.  :-\

bzman24

  • Jr. Member
  • **
  • Posts: 71
Re: hyphen turns to question mark
« Reply #12 on: October 28, 2014, 01:45:17 am »
I've seen ASCII 151 that looks like an elongated hyphen.  In HTML it looks like a double hyphen but when converted to text it looks real close to a real hyphen (ASCII 45).  Is this a 'soft hyphen'? If not what is a 'soft hyphen' and why is it called that?

Curious
==============
OS: Win7 - i5 - win64
Linux Mint 17.3
Lazarus: V1.8.2 / FPC - 3.0.4

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1260
Re: hyphen turns to question mark
« Reply #13 on: October 28, 2014, 02:58:49 am »
Follow the link for the wiki on soft hyphen.

It is a hyphen, actually a "soft hyphen".
Lazarus Trunk/FPC Trunk on Windows [7, 10]
  Have you tried searching this forum or the wiki?:   http://wiki.lazarus.freepascal.org/Alternative_Main_Page
  BOOKS! (Free and otherwise): http://wiki.lazarus.freepascal.org/Pascal_and_Lazarus_Books_and_Magazines

bzman24

  • Jr. Member
  • **
  • Posts: 71
Re: hyphen turns to question mark
« Reply #14 on: October 28, 2014, 03:34:25 am »
Mike,  Something that we have been using for years to show broken words and never knew they were called that.  Learn something new all the time.  Thanks.  Bzman
==============
OS: Win7 - i5 - win64
Linux Mint 17.3
Lazarus: V1.8.2 / FPC - 3.0.4

 

TinyPortal © 2005-2018