From: Jim C. <jim...@gm...> - 2007-07-11 07:12:40
|
Hello, I have a problem in converting a binary data into a character buffer which is read by a C++ function using wrapper generated by SWIG. I create a variable 'b' in TCL, and store in it a binary value as hex string. Then, I do "% set t [binary format H* $b]" to convert it into actual binary. Then, I pass it as argument to the SWIG wrapper for my C++ function, which just accepts char* pointer and number of bytes, and prints binary value of each separate bytes. I can see that in my C++ function, I get 2 characters instead of 1. My original byte is pre-fixed by a byte called 0xC2. This happens when I pass a binary string also. Every binary byte is pre-fixed by 0xC2. Can some one tell me where is the problem, and how to solve it? >From TCL, it looks fine to me. Is it a problem with SWIG wrapper doing some internal conversion? ########### See the script below ############ % load example.dll % MyClass myObj _e04c0a01_p_MyClass % set b b0 b0 % set t [binary format H* $b] =B0 % myObj WRAP_TestFn $t 1 [3268] WRAP_TestFn pData: 0xc2 % myObj WRAP_TestFn $t 2 [3268] WRAP_TestFn pData: 0xc2 0xb0 % ########### End ############ ########### C++ code ############ |