Skip to Content
avatar image
Former Member

SAP Unicode RFC types

Could anybody provide clear definitions and usage examples for the following 'character' types in the SAP RFCSDK (in addition to the comments in the source code:)?

- rfc_char_t




- ?

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Apr 13, 2011 at 02:33 PM

    If you are using the non-Unicode RFC SDK, all four types basically typedef to char. So they basically represent one-byte character data like ISO-Latin-1, Micorsoft CP1252 etc, depending on the platform you run.

    If you are using the Unicode RFC SDK or the NetWeaver RFC SDK, then all four types represent platform-independent 2-byte UTF-16 data. On Windows they typedef to wchar_t (because Windows uses 2-byte UTF-16 as its Unicode representation), on Linux and most Unixes they typedef to a 2-byte unsigned short. (Which is different from wchar_t in most cases, as most Unixes use a 4-byte wchar_t.)

    Don't forget to compile you code with -DSAPwithUNICODE, otherwise you'll get segmentation fautls as the buffers you feed into the RFC APIs is only half as long as the RFC APIs expect them to be....

    This is most convenient, of your program is Unicode anyway. However, if you program is processing non-Unicode data that it gets from other legacy libraries, databases, user input, etc, you first need to convert from your platform encoding to UTF-16, before passing the data to the RFC APIs. If you are running on Linux, where the platform is using UTF-8 as its default encoding, you can simply use the API RfcUTF8ToSAPUC() (and the corresponding RfcSAPUCToUTF8() for the other way around) to convert to the SAP_UC type (and back). (This API is available in the NetWeaver RFC SDK.)

    If you are dealing with let's say ISO-Latin-1 for example, you could use standard GNU functions iconv_open() and iconv() to convert from ISO-Latin-1 to UTF-16. (Giving a pointer to a SAP_UC[] as "outbuf" in the iconv() call.) See [|] and also


    I think libiconv is available on all Unixes and Linux distributions these days.

    On Windows we have the MultiByteToWideChar(), WideCharToMultiByte(), etc functions, which convert to wchar_t and back. (Despite their name, they can handle single-byte codepages like CP1252 as well....)

    Best Regards, Ulrich

    Add comment
    10|10000 characters needed characters exceeded