INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Unicode CSV file fails to reveal data with FILETOSTR() Help

Unicode CSV file fails to reveal data with FILETOSTR() Help

(OP)
Hi guys...

I am getting unicode CSV files from an application and the FILETOSTR() function takes a 13 meg file to 3 characters

_cliptext = FILETOSTR("F:\VFP Projects\FUN\.UK100CashM15.csv")

How can I convert unicode files to ANSI whatever format will work in VFP?

TIA

Dennis Kean

Simplicity is the extreme degree of sophistication.
Leonardo da Vinci

RE: Unicode CSV file fails to reveal data with FILETOSTR() Help

FILETOSTR() result will be fine, the only reason I see causing a problem is using _cliptext.

VFP strings can take 13meg no problem and also can contain any byte. Not every byte will be "printable", but you get the full file content, no matter whether it is ansi, unicode, binary, anything.

When you put something into _cliptext CHR(0) might cause to end this and when you paste the _cliptext you only get 3 characters, but that's not the influence of FILETOSTR(), it is _cliptext doing that.

I haven't tried this, but I am very sure lcFile = FILETOSTR("F:\VFP Projects\FUN\.UK100CashM15.csv") will work out. Look at LEN(lcFile).

Bye, Olaf.

RE: Unicode CSV file fails to reveal data with FILETOSTR() Help

(OP)
Thanks for the quick response, Olaf,

You were correct, I just used that to test it in command. But I do get the following problem if I operate on the string of the unicode file.

STRTRAN(la,",",", ")
lb = STRTRAN(la,",",", ")
STRTOFILE(lb,"F:\VFP Projects\Trading\MT5\.UK100CashM15_.csv")


Here is the result:
2017.05.11 09:00‬㜀㌀㜀㐀⸀㔀    Ⰰ 7377.50000‬㜀㌀㜀㄀⸀     Ⰰ 7373.50000‬㄀㠀㐀Ⰰ 0
2017.05.11 09:15‬㜀㌀㜀㌀⸀㔀    Ⰰ 7377.50000‬㜀㌀㜀㈀⸀     Ⰰ 7374.50000‬㄀ ㈀Ⰰ 0
2017.05.11 09:30‬㜀㌀㜀㔀⸀     Ⰰ 7378.50000‬㜀㌀㜀㔀⸀     Ⰰ 7378.00000‬㤀㘀Ⰰ 0
2017.05.11 09:45‬㜀㌀㜀㜀⸀㔀    Ⰰ 7378.50000‬㜀㌀㜀㄀⸀     Ⰰ 7373.00000‬㄀㜀 Ⰰ 0
2017.05.11 10:00‬㜀㌀㜀㐀⸀㔀    Ⰰ 7384.50000‬㜀㌀㘀㘀⸀     Ⰰ 7377.00000‬㄀㠀㄀㔀Ⰰ 0
2017.05.11 10:15‬㜀㌀㜀㜀⸀     Ⰰ 7387.50000‬㜀㌀㜀㘀⸀     Ⰰ 7385.00000‬㤀㈀㠀Ⰰ 0



And it kills two columns out of 5:

Dennis

Dennis Kean

Simplicity is the extreme degree of sophistication.
Leonardo da Vinci

RE: Unicode CSV file fails to reveal data with FILETOSTR() Help

Well, as you say this is Unicode and you can't display Unicode in VFP, there also is no conversion for most bytes looking like gibberish when displayed with their ANSI character, even more so because the string would only be 1/2 as wide in real unicode font display.

The closest you will get is by converting lcFile after FILETOSTR via STRTRAN(lcFile,6). 6 means Unicode to DBCS, which is fine. Don't get the idea you need a second STRCONV with 2=DBCS to single byte. Don't ask why.

Bye, Olaf.


RE: Unicode CSV file fails to reveal data with FILETOSTR() Help

Anyway, to precess this data, find something else, you won't be able to process unicode in VFP, even if you would make use of ATC(),SUBSTRC() and all the other string functions for double byte characters.

Unicode should stay unicode, and C# would be fine for processing such data, for example.

Bye, Olaf.

RE: Unicode CSV file fails to reveal data with FILETOSTR() Help

(OP)
Olaf,

You must have had some other function in mind... STRTRAN(lcFile,6) Generates an error.

Dennis Kean

Simplicity is the extreme degree of sophistication.
Leonardo da Vinci

RE: Unicode CSV file fails to reveal data with FILETOSTR() Help

(OP)
I see you meant STRCONV(lcFil,e,6)


Thanks Olaf!

Dennis Kean

Simplicity is the extreme degree of sophistication.
Leonardo da Vinci

RE: Unicode CSV file fails to reveal data with FILETOSTR() Help

Dennis,

STRCONV(lcfile,6)

hth

n

RE: Unicode CSV file fails to reveal data with FILETOSTR() Help

(OP)
nigelgomm,

Thanks Nigelgom... my mistake. I don't know where that "e," came from.... Tested it and it works fine...

Dennis Kean

Simplicity is the extreme degree of sophistication.
Leonardo da Vinci

RE: Unicode CSV file fails to reveal data with FILETOSTR() Help

Yes, I meant STRCONV.

Bye, Olaf.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close