#1
Posted
:
Sunday, August 13, 2017 4:26:37 PM(UTC)
Groups: Registered
Posts: 11
Thanks: 1 times
Hi,
I am using L_LoadBitmap based functions for my OCR and noticed that it take L_TCHAR pointers while rest of the UI work in String based. Are there API functions that take String or some easy way of converting String to L_TCHAR? I am sure someone would have encountered this before.
#2
Posted
:
Thursday, August 17, 2017 3:17:24 PM(UTC)
Groups: Registered, Tech Support, Administrators
Posts: 63
Thanks: 2 times
Was thanked: 4 time(s) in 4 post(s)
Converting from a String to an L_TCHAR requires a few simple steps.
First, you must convert your existing String to a CString object using the c_str() function. This will give you a 'C' compatible string to work with. Note, a 'C' compatible string is a char array.
From here, you would then cast this array into a T_CHAR. Finally you can cast this T_CHAR array into an L_TCHAR to obtain your desired output. I'll include sample code of performing these steps below.
Code:
string test = "C:\\Users\\Public\\Documents\\LEADTOOLS Images\\cannon.jpg";
CString out = test.c_str();
L_TCHAR* newout = (L_TCHAR*)((LPCTSTR)out);
Joe Zhan
Developer Support Engineer
LEAD Technologies, Inc.
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.