1. Andres Slachevsky
  2. PowerBuilder
  3. Monday, 17 December 2018 11:59 AM UTC

Hello All,,

PB2017 R3 Windows 10

i have a file with a Ñ on it

Using importFile it converts the Ñ to 2 strange characters

using File functions it also create the same problem 

the only solution i found is to replace the characters after the import or fileread

i have try every enconding in the importfile 

i am attaching a simple file as an example

 

Attachments (1)
Arthur Hefti Accepted Answer Pending Moderation
  1. Monday, 17 December 2018 12:46 PM UTC
  2. PowerBuilder
  3. # 1

Hi 

you need a BOM that PB knows which format the file is. Without BOM it thinks you're loading ANSI but the file is UTF-8. If not possible you can use FileOpen/Read and provide the format then use importstring.

https://en.wikipedia.org/wiki/Byte_order_mark

Regards
Arthur

 

Comment
  1. Andres Slachevsky
  2. Monday, 17 December 2018 12:55 PM UTC
I get the file from a third party, when i try to open the file with any parameter in the enconding (other than ANSI!) i get -1
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Monday, 17 December 2018 16:27 PM UTC
  2. PowerBuilder
  3. # 2

Hi Andres;

  Your attached file was in ANSI format.

I converted it to Unicode. Please give that a try!

HTH

Regards ... Chris

Attachments (1)
Comment
  1. Andres Slachevsky
  2. Tuesday, 18 December 2018 11:19 AM UTC
Thanks Chris.

if the file is a Unicode file it works.

the problem is that we have no control on the file.

i will check if there is any way to convert the file without en user action

  1. Helpful
  1. Chris Pollach @Appeon
  2. Tuesday, 18 December 2018 18:34 PM UTC
Hi Andres;



Suggestion: I would use the following coding approach ...



1) Use the FileEncoding() PB command to determine if the import file is Unicode

2) If not, read the file into your PB app using FileReadEx() specifying ANSI

3) Use a FileOpen() to create a new Unicode file and then use FileWriteEx() write original data back out in Unicode format.



After the above steps, Import the new Unicode file as required.



HTH

Regards ... Chris

  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.