Recent

Author Topic: UTF8ToCP1250 + DLLs stopped working after conversion to CT 6.1  (Read 2155 times)

yellowbit

  • New Member
  • *
  • Posts: 22
I've recently upgraded my project to CodeTyphon 6.1. It usses a DLL function that receives a string (PAnsiChar). DLL is a C++ project and uses strings encoded in CP1250.

Code: Pascal  [Select][+][-]
  1. type TDLLDoSomething = procedure(seq: PAnsiChar); cdecl;  
  2.  
  3. ...
  4.  
  5. var DLLDoSomething: TDLLDoSomething ;
  6.  
  7. ...
  8.  
  9. DLLDoSomething(PAnsiChar(UTF8ToAnsi(textFromUI))); // also tried UTF8ToCP1250


In old CT (5.5) it was ok. After upgrade the DLL receives text in UTF8 (2 bytes per special char)...
Function UTF8ToCP1250 seems to be ok but the DLL gets wrong string anyway. I have no idea how to fix it.  Converting this project back to CT 5.5 will be a pain because file formats have been changed. Can anyone help?
« Last Edit: July 23, 2017, 01:30:27 pm by yellowbit »

wp

  • Hero Member
  • *****
  • Posts: 11830
Re: UTF8ToCP1250 + DLLs stopped working after conversion to CT 6.1
« Reply #1 on: July 23, 2017, 01:34:48 pm »
This is a forum for Lazarus/FPC, not for CodeTyphoon. Please post your question in the CT forum.

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: UTF8ToCP1250 + DLLs stopped working after conversion to CT 6.1
« Reply #2 on: July 23, 2017, 11:59:36 pm »
Converting this project back to CT 5.5 will be a pain because file formats have been changed. Can anyone help?
Conversion of 6.10 back to 5.50 can be done with ct2laz.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

sam707

  • Guest
Re: UTF8ToCP1250 + DLLs stopped working after conversion to CT 6.1
« Reply #3 on: July 24, 2017, 01:50:46 am »
other languages are using some naming when exporting from libraries, I did read something about that on the wiki by past ... i did not retreive the article at the moment.

You NEED to use a "DLL exports viewver" (3rd party software) to get exact name of your function

for exemple I did notice on a C++ written dll, the name of "char *decrypt(char *) became

_decrypt@_4 in the exports of the dll, because it was a fastcall function taking an argument as pointer which was  4 byte long

so I gave the exact nameS found by a 3rd party dll exports finder (instead of those 'brute' in the 'h' C++ header), and all went ok after that

kind of declaration (if i remeber) =>

function decrypt (s: pchar): pchar; cdecl; external 'mydllname' name '_decrypt_@4';
« Last Edit: July 24, 2017, 02:14:06 am by sam707 »


 

TinyPortal © 2005-2018