Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

Some ANSI characters read from ISAM files do not display correctly in WPF TextBox controls

Some ANSI characters read from ISAM files do not display correctly in WPF TextBox controls

Problem:

Customer has an application that is reading an indexed file which contains sveral fields defined as PIC X.
These fields may contain ANSI characters like the German ä/ö/ü/ß"...

After reading a record and moving a field containing these characters to a TextBox control the characters are not being displayed properly.

The move statement looks like:

      move field1 to textBox1::Text

How can these characters be displayed correctly in the textbox control?

Resolution:

If the field that you are reading in is defined as PIC X then it will be read as ANSI data.

The TextBox::Text property uses Unicode as do all .NET strings so the data needs to be converted before it is displayed.

The following example will work where my-ansi-field would contain German characters read from a file:

   01 my-ansi-field pic x(5).
   01 myarray type Byte[].
...
        set myarray to my-ansi-field
        set self::textBox1::Text to type System.Text.Encoding::Default::GetString(myarray)

 

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2013-10-25 17:28
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.