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

ascii CHR 160 - non-breaking space 1

Status
Not open for further replies.

David Higgs

Programmer
May 6, 2012
405
GB
I have suspected for sometime that a Database of mine has some "hidden" issues.

When I searched for e.g "A1ABC" I found 11 Records and when I searched for "A1ABC " I only found 4 Records. I found the 4 Records were showing a LEN = 6 and that the 6th CHR was a ascii CHR 160 (non-breaking space).

The FIELD Type = CHARACTER and the Width = 12. The actual Length can vary between 4 to 12 Characters and there are 20700 Records.

What would be the easiest way to remove the ascii CHR 160

Regards,
David
 
If cText is the field containing the unwanted characters:

Code:
REPLACE cText WITH STRTRAN(cText, CHR(160), "")

If you want to replace the unwanted characters with normal spaces:

Code:
REPLACE cText WITH STRTRAN(cText, CHR(160), [b]" "[/b])

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
I'd go for replacing CHR(160) with CHR(32), as such spaces might also be in places you want a visible space, yet a normal space.

So I'd opt for REPLACE ALL cText WITH CHRTRAN(cText, CHR(160), " ")

To ensure a normal space you can also take CHR(32) or SPACE(1) instead of " ".

Bye, Olaf.

 
Mike,

Many thanks for your reply. I'm just getting over a head cold and couldn't get my head round a solution. Needless to say your solution worked 100%.






Regards,
David
 
Olaf,

Thanks for your reply. I used Mike's second suggestion to replace CHR(160) with a Space.

Regards,
David
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top