1. Andres Slachevsky
  2. PowerBuilder
  3. Monday, 17 December 2018

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)
Chris Pollach Accepted Answer Pending Moderation
0
Votes
Undo

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
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. Andres Slachevsky
  2. Tuesday, 18 December 2018
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. Chris Pollach
  2. Tuesday, 18 December 2018
There are no comments made yet.
  1. Monday, 17 December 2018
  2. PowerBuilder
  3. # 1
Arthur Hefti Accepted Answer Pending Moderation
0
Votes
Undo

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
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. Andres Slachevsky
  2. Monday, 17 December 2018
There are no comments made yet.
  1. Monday, 17 December 2018
  2. PowerBuilder
  3. # 2
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies. Learn More