Unicode Support in the C++ Editions


Unicode characters can be used in all of our editions, including the C++ editions. This KB entry will cover how to work with Unicode in the C++ editions. When working with Unicode, wide character strings should be used anytime a regular string is required.

Support for Unicode is handled differently in newer versions (2020+) than older versions. This KB covers how to work with all versions and additionally how to update old code.

Newer Versions (2020+)

In 2020 and later, Unicode support is handled with a set of header files that allow the components to work with wide character strings. To use them add the <installation directory>/include/unicode folder to your include path.

Updating old code...

To update older code only these two steps should be required:

  1. Update the include path to point to <installation directory>/include/unicode.
  2. Remove the "W" suffix from any class/type name.

Older Versions (2016-)

In 2016 and older, Unicode support is handled with a set of parallel classes that work with wide character strings. These classes have the same name as the regular classes, but with a W suffix (e.g. IPPort with Unicode support is IPPortW).

Examples

These examples are functionally equivalent.

2016 2020

class mySFTP : public SFTPW {
public:
  virtual int FireSSHServerAuthentication(SFTPSSHServerAuthenticationEventParamsW* e) {
    e->Accept = true;
    return 0;
  }
  virtual int FireSSHStatus(SFTPSSHStatusEventParamsW* e) {
    OutputDebugStringW(e->Message);
    return 0;
  }
};
int main()
{
  mySFTP sftp;
  sftp.SetSSHUser((LPWSTR)L"user");
  sftp.SetSSHPassword((LPWSTR)L"password");
  sftp.SSHLogon((LPWSTR)L"sftp.server.com", 22);
  sftp.ListDirectory();
  sftp.SSHLogoff();
}

class mySFTP : public SFTP {
public:
  virtual int FireSSHServerAuthentication(SFTPSSHServerAuthenticationEventParams* e) {
    e->Accept = true;
    return 0;
  }
  virtual int FireSSHStatus(SFTPSSHStatusEventParams* e) {
    OutputDebugStringW(e->Message);
    return 0;
  }
};
int main()
{
  mySFTP sftp;
  sftp.SetSSHUser((LPWSTR)L"user");
  sftp.SetSSHPassword((LPWSTR)L"password");
  sftp.SSHLogon((LPWSTR)L"sftp.server.com", 22);
  sftp.ListDirectory();
  sftp.SSHLogoff();
}

We appreciate your feedback. If you have any questions, comments, or suggestions about this article please contact our support team at support@nsoftware.com.