Permalink
Browse files

Fix unicode handling of strings

Signed-off-by: Piers Harding <piers@catalyst.net.nz>
  • Loading branch information...
piersharding committed Oct 4, 2011
1 parent 011868c commit 787f6c161ad85d25dda9c166cf598203385655a6
Showing with 14 additions and 3 deletions.
  1. +3 −0 ChangeLog
  2. +11 −3 src/nwsaprfcutil.c
View
@@ -28,3 +28,6 @@ Added fixes, typos, and silly debug comments + removed dependence on py yaml - t
Fri Jul 15 06:16:44 NZST 2011
Fix incorrect type coersion for error handling - thanks guettli (Thomas Güttler)
Wed Oct 5 05:33:43 NZDT 2011
* fix unicode handling of strings - thanks guettli (Thomas Güttler)
View
@@ -155,14 +155,22 @@ SAP_UC * u8to16(PyObject *str) {
RFC_ERROR_INFO errorInfo;
SAP_UC *sapuc;
unsigned sapucSize, resultLength;
PyObject *tmp;
sapucSize = PyString_Size(str) + 1;
if (PyUnicode_Check(str)) {
tmp = PyUnicode_AsUTF8String(str);
}
else {
tmp = str;
}
sapucSize = PyString_Size(tmp) + 1;
sapuc = mallocU(sapucSize);
memsetU(sapuc, 0, sapucSize);
resultLength = 0;
rc = RfcUTF8ToSAPUC((RFC_BYTE *)PyString_AsString(str), PyString_Size(str), sapuc, &sapucSize, &resultLength, &errorInfo);
rc = RfcUTF8ToSAPUC((RFC_BYTE *)PyString_AsString(tmp), PyString_Size(tmp), sapuc, &sapucSize, &resultLength, &errorInfo);
return sapuc;
}
@@ -1423,7 +1431,7 @@ void set_char_value(DATA_CONTAINER_HANDLE hcont, SAP_UC *name, PyObject * value,
RFC_ERROR_INFO errorInfo;
SAP_UC *p_value;
if (! PyString_Check(value)){
if (! PyString_Check(value) && !PyUnicode_Check(value)){
SAPNW_rfc_call_error1("RfcSetChar invalid Input value type:", PyString_AsString(PyObject_Repr(value)));
return;
}

0 comments on commit 787f6c1

Please sign in to comment.