Author Topic: Rexx -> IBM C  (Read 1204 times)

André Heldoorn

  • Sr. Member
  • ****
  • Thank You
  • -Given: 38
  • -Receive: 9
  • Posts: 371
    • View Profile
Re: Rexx -> IBM C
« Reply #15 on: October 26, 2018, 04:22:15 pm »
help chcp

And check the settings notebook of any program. Here there is a page named 'Sprache'.

Please do not change your codepage setting in your config.sys.

Well spotted. Einverstanden. CONFIG.SYS would have been my first weapon of choice, because here this setting is always the default.

I did remember CHCP somehow, while not using OS/2 at the moment, but did't think of its HELP. Thanks.

Bogdan Szmalcownik

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 37
    • View Profile
Re: Rexx -> IBM C
« Reply #16 on: October 26, 2018, 08:52:37 pm »
1. I cannot check my OS-2 CODEPAGE setting right now, but the default is 850. Does 850,437 mean that I can swap at the OS level (STDOUT, et cetera) to 437 , while an app may use e.g. 860 "internally"?
No

Quote
2. Do all systems have a 850 by default?
No
Quote
IOW, would a Portugese OS/2 version have the setting 860,850? Portugese by default, with the international 850 as an option? Or reversed, 850,860.
It depends on which Portuguese language version is used. In doubt DosQueryCp should answer correctly.

André Heldoorn

  • Sr. Member
  • ****
  • Thank You
  • -Given: 38
  • -Receive: 9
  • Posts: 371
    • View Profile
Re: Rexx -> IBM C
« Reply #17 on: October 31, 2018, 05:44:37 am »
Quote
IOW, would a Portugese OS/2 version have the setting 860,850? Portugese by default, with the international 850 as an option? Or reversed, 850,860.

It depends on which Portuguese language version is used. In doubt DosQueryCp should answer correctly.

Fortunately codepage 860 is one of the codepages which can be used, because the relevant characters are identical. I still have to look at the APIs you've mentioned earlier. I did RTFM, but it's not that obvious how it works.

Avoiding the superscript 1, 2 & 3 is implemented now. Those characters often are different/missing. Previously a superscript 1 was appended to a name and converted to "¹", but now this is a suffix (inside the same struct as the nme) which is "\0" or "¹\0".

I've seen that even the "&" isn't always the same character per codepage, so I may need the APIs anyway. Homework... No programming guide, and no clear output of sample code...

André Heldoorn

  • Sr. Member
  • ****
  • Thank You
  • -Given: 38
  • -Receive: 9
  • Posts: 371
    • View Profile
Re: Rexx -> IBM C
« Reply #18 on: November 03, 2018, 07:14:21 pm »
I'v decided to not embed UCONV now, because it introduces more problems that it will solve. Like a HTLMNAME.DLL, which could be the prefered solution. After all I'm not writing a single, generic TXT2HTML.EXE.

It's not that simple, for one because e.g. http://www.edm2.com/index.php/UniCreateUconvObject produces quite a few return codes instead of clear output.

Of course I will keep it in mind. And I've reduced the number of high-ASCII characters which are too rare. An appended "¹"is no longer being converted to "¹" as part of a name. Instead the name is converted, and next "¹" is appended.

André Heldoorn

  • Sr. Member
  • ****
  • Thank You
  • -Given: 38
  • -Receive: 9
  • Posts: 371
    • View Profile
Re: Rexx -> IBM C
« Reply #19 on: November 05, 2018, 12:03:23 pm »
I'v decided to not embed UCONV now, because it introduces more problems that it will solve. Like a HTLMNAME.DLL, which could be the prefered solution. After all I'm not writing a single, generic TXT2HTML.EXE.

Below is a test version of the code I'll use in one of the existing data file verification steps.

According to the documentation of DosSetProcessCp() the number of implied supported codepages is 6. If the current codepage is not supported, then it prints a warning. If an installed (CODEPAGE=xxx,yyy] codepage is supported, then it suggests to switch codepages when needed. If none of the installed codepages is supported , then it prints a list of supported codepages. Which doesn't really help an user, but that's a rather theoretical situation anyway because th euser will be somehow mixing foreign and native words anyway.

The code itself is not that useful, and should be basic stuff for experienced programmers. The main progress is that using a specific codepage, Rexx won't be aware of any, is no longer assumed.

Code: [Select]
#define INCL_DOSERRORS
#define INCL_DOSNLS
#define CODEPAGES 6

#include <os2.h>
#include <stdio.h>

int main(void)
{
APIRET rc=NO_ERROR;
ULONG aulCpList[8]={0},codepages[CODEPAGES]={437,850,857,860,861,865},found=0,i,j,ulBufSize=8*sizeof(ULONG),ulListSize=0;

rc=DosQueryCp(ulBufSize,aulCpList,&ulListSize);
if (rc==NO_ERROR)
   {
   aulCpList[0];
   for (i=0;i<CODEPAGES;i++)   
      if (codepages[i]==aulCpList[0])
         found=1;
   if (!found)
      {
      printf("Warning: codepage %u is not supported.\n",aulCpList[0]);
      for (i=0;i<ulListSize/sizeof(ULONG);i++)
         if (aulCpList[i]!=aulCpList[0])
            {
            found=99999;
            for (j=0;j<CODEPAGES;j++)   
               if (aulCpList[i]==codepages[j])
                  found=j;
            if (found!=99999)
               printf("Execute the OS/2 command \"CHCP %u\" before creating or editing data files.\n",codepages[found]);
            else
               {
               printf("Supported codepages are:\n\n");
               for (j=0;j<CODEPAGES;j++)
                  printf("%u\n",codepages[j]);   
               }
            }
      }
   }

return 0;
}