提交 36e26330 编写于 作者: L liu0x54

[TD251]fix python connector to process NCHAR

上级 b8a8ed0c
...@@ -96,7 +96,8 @@ def _crow_nchar_to_python(data, num_of_rows, nbytes=None, micro=False): ...@@ -96,7 +96,8 @@ def _crow_nchar_to_python(data, num_of_rows, nbytes=None, micro=False):
for i in range(abs(num_of_rows)): for i in range(abs(num_of_rows)):
try: try:
if num_of_rows >= 0: if num_of_rows >= 0:
res.append( (ctypes.cast(data+nbytes*(abs(num_of_rows - i -1)), ctypes.POINTER(ctypes.c_char * (nbytes//4))))[0].value ) tmpstr = ctypes.c_char_p(data)
res.append( tmpstr.value.decode() )
else: else:
res.append( (ctypes.cast(data+nbytes*i, ctypes.POINTER(ctypes.c_wchar * (nbytes//4))))[0].value ) res.append( (ctypes.cast(data+nbytes*i, ctypes.POINTER(ctypes.c_wchar * (nbytes//4))))[0].value )
except ValueError: except ValueError:
......
...@@ -96,7 +96,8 @@ def _crow_nchar_to_python(data, num_of_rows, nbytes=None, micro=False): ...@@ -96,7 +96,8 @@ def _crow_nchar_to_python(data, num_of_rows, nbytes=None, micro=False):
for i in range(abs(num_of_rows)): for i in range(abs(num_of_rows)):
try: try:
if num_of_rows >= 0: if num_of_rows >= 0:
res.append( (ctypes.cast(data+nbytes*(abs(num_of_rows - i -1)), ctypes.POINTER(ctypes.c_char * (nbytes//4))))[0].value ) tmpstr = ctypes.c_char_p(data)
res.append( tmpstr.value.decode() )
else: else:
res.append( (ctypes.cast(data+nbytes*i, ctypes.POINTER(ctypes.c_wchar * (nbytes//4))))[0].value ) res.append( (ctypes.cast(data+nbytes*i, ctypes.POINTER(ctypes.c_wchar * (nbytes//4))))[0].value )
except ValueError: except ValueError:
......
...@@ -96,7 +96,8 @@ def _crow_nchar_to_python(data, num_of_rows, nbytes=None, micro=False): ...@@ -96,7 +96,8 @@ def _crow_nchar_to_python(data, num_of_rows, nbytes=None, micro=False):
for i in range(abs(num_of_rows)): for i in range(abs(num_of_rows)):
try: try:
if num_of_rows >= 0: if num_of_rows >= 0:
res.append( (ctypes.cast(data+nbytes*(abs(num_of_rows - i -1)), ctypes.POINTER(ctypes.c_char * (nbytes//4))))[0].value ) tmpstr = ctypes.c_char_p(data)
res.append( tmpstr.value.decode() )
else: else:
res.append( (ctypes.cast(data+nbytes*i, ctypes.POINTER(ctypes.c_wchar * (nbytes//4))))[0].value ) res.append( (ctypes.cast(data+nbytes*i, ctypes.POINTER(ctypes.c_wchar * (nbytes//4))))[0].value )
except ValueError: except ValueError:
......
...@@ -96,7 +96,8 @@ def _crow_nchar_to_python(data, num_of_rows, nbytes=None, micro=False): ...@@ -96,7 +96,8 @@ def _crow_nchar_to_python(data, num_of_rows, nbytes=None, micro=False):
for i in range(abs(num_of_rows)): for i in range(abs(num_of_rows)):
try: try:
if num_of_rows >= 0: if num_of_rows >= 0:
res.append( (ctypes.cast(data+nbytes*(abs(num_of_rows - i -1)), ctypes.POINTER(ctypes.c_char * (nbytes//4))))[0].value ) tmpstr = ctypes.c_char_p(data)
res.append( tmpstr.value.decode() )
else: else:
res.append( (ctypes.cast(data+nbytes*i, ctypes.POINTER(ctypes.c_wchar * (nbytes//4))))[0].value ) res.append( (ctypes.cast(data+nbytes*i, ctypes.POINTER(ctypes.c_wchar * (nbytes//4))))[0].value )
except ValueError: except ValueError:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册