Skip to main content
Question

cobutf8 utility

  • February 10, 2026
  • 1 reply
  • 21 views

M Carmen De Paz
Forum|alt.badge.img+2
Good morning.I'd like someone to explain how the cobutf8 utility works to see if we can use it in our company.We work with Microfocus Visual COBOL 8.0 for Eclipse (Unix/Linux).The database is Informix, and a few years ago we migrated to the UTF-8 locale.The OS has LANG=es_ES.UTF-8.However, some integrations with other companies require files with a fixed position structure. We've found that with UTF-8 encoding, there's a left shift for each UTF-8 character written. Currently, we've added calls to iconv before each move to the file variable, but that's very cumbersome when the file has many fields.

1 reply

Chris Glazier
Forum|alt.badge.img+3

I have done some research on this utility, and I don’t think it will be useful for what you are trying to accomplish.

It doesn’t actually do any conversion of the underlying bytes that represent the characters. What it does is look up the UTF-8 character codes and then map these onto the codes in the target locales character set that has the same character display representation.  When a program is run under control of cobutf8, it is assumed that the underlying character codes are from the target character set and it will display that value. When not run under cobutf8 it will display the UTF-8 characters with the same code value.

Here is a small program that demonstrates this:

 $set sourceformat"variable"
       id division.
       program-id. cp1252test.
       data division.
       working-storage section.
       01 my-utf8       pic x(10)  value "Café".  *> These are in UTF8
       01 my-1252       pic x(10)  value x"436166E9". *> CP1252 equivalent
       procedure division.
          display "UTF8 version = " my-utf8
          display "1252 version = " my-1252
          stop run.

 

The current LANG is en.US.UTF-8 and COBUTF8 is set to en_US.cp1252

When run under the cobutf8 utility the 1252 version will display correctly and the UTF-8 one will not.

When run without cobutf8 this will be reversed. 

This utility is to control the characters that are displayed for a specified code but doesnt change the underlying code at all.