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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting the Sterling £ sign

Status
Not open for further replies.

AndrewMozley

Programmer
Oct 15, 2005
621
GB
There is a DOS application where I am converting the data into records in a VFP database.

In several character fields there may be a sterling £ sign; I see that this is stored as hexadecimal ‘9C’.

If the field is just copied across, when I print the character string it shows as a diphthong (ligature) œ; When browsing it under VFP shows as a vertical black rectangle.

I understand that the character code in a VFP table for this sterling sign should by hexadacimal ‘A3’ and that I can revise my conversion routine, so that in each field in each table where the ‘£’ sign might appear I apply this conversion :

Code:
 Newtext = CHRTRANC(OldText, CHR(156), CHR(163))

Is there a better way of doing this?

Thanks. Andrew
 
It's many, many years since I have done this. But the last time I opened a FoxPro (or FoxBase) DOS file in VFP, it prompted for a code page. I think I selected "Windows ANSI", which did the trick, but I can't swear to it.

But, in the absence of that facility, I would say that your approach is as good as any.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
If you will always be dealing with single-byte characters, then CHRTRAN (which can handle multiple character conversions at once) should be sufficient. From VFP 9 Help:
CHRTRANC( ) is designed to facilitate working with expressions that contain double-byte characters. Use CHRTRANC( ) to replace single-byte characters with double-byte characters or double-byte characters with single-byte characters. If the expressions contains only single-byte characters, CHRTRANC( ) is equivalent to CHRTRAN( ).

 
dbMark, you're right. I didn't notice that Andrew was using CHRTRANC() rather than CHRTRAN().

Personally, I would use STRTRAN() in this situation, as the replacement is strictly one-for-one, but CHRTRAN() would also work.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thank you both.

I have led a sheltered life and do not remember using either CHRTRAN or STRTRAN recently. But I take your point, dbMark, that CHRTRAN is sufficient, since I am not using double-byte characters. I will use CHRTRAN()

Andrew M.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top