Tuesday, January 24, 2023

Install Fastdb in CentOS

环境: CentOS 6.4 32位

注意:

64位运行有问题,运行最后会报 segmentation fault,所以最后采用32位操作系统。

1.1 安装
(1) 安装需要的依赖

yum install gcc make gcc-c++ wget
(2) 下载源码

wget http://www.garret.ru/fastdb-3.76.tar.gz
(3) 解压

tar -xvf fastdb-3.76.tar.gz
(4) 切换到目录

cd fastdb
(5) 配置安装目录 /opt/fastdb

./configure --prefix=/opt/fastdb
(6) 编译

make -j16
(7) 安装

make install
(8) 注意事项

Linux下运行程序提示:

Incompatibility between headers and library

fastdb会假设绝大多数的Linux版是64-bit,如果你的机子是32-bit的,必须将config.h文件的如下内容注释掉:

// #if !defined(_WIN32) || defined(_WIN64) // most unixes are now 64-bit, while 32-bit windows is still quite popular
 
// #define LARGE_DATABASE_SUPPORT
 
//

Tuesday, July 13, 2021

URLEncode, Change a text to URL Code

TIdURI::URLEncode(__classid(TIdURI),
UTF8Encode("https://wa.me/85221361756?text=我想查詢軟件")))

Tuesday, May 25, 2021

Unicode escape to utf-8

int get_uint8(int h, int l)
{
    int ret;

    if (h - '0' < 10)
        ret = h - '0';
    else if (h - 'A' < 6)
        ret = h - 'A' + 0x0A;
    else if (h - 'a' < 6)
        ret = h - 'a' + 0x0A;

    ret = ret << 4;

    if (l - '0' < 10)
        ret |= l - '0';
    else if (l - 'A' < 6)
        ret |= l - 'A' + 0x0A;
    else if (l - 'a' < 6)
        ret |= l - 'a' + 0x0A;
    return  ret;
}


AnsiString UniToAnsi(char *s)
{
    wchar_t *ws=new wchar_t(strlen(s));
    int c=0;
    while (*s !='\0' )
    {
        if (*s == '\\')
        {
            if (strlen(s) > 5)
            {
                if (*(s + 1) == 'u')
                {
                    unsigned int v = get_uint8(*(s + 2), *(s + 3)) << 8;
                    v |= get_uint8(*(s + 4), *(s + 5));

                    s += 6;
                    ws[c]=wchar_t(v);
                    c++;
                    continue;
                }
            }
        }
        s++;
    }
    ws[c]='\0';
    AnsiString ret=UTF8Decode(UTF8Encode(ws));
    delete ws;
    return ret;
}


Input: char *str="\u82b3TEST\u8349\u827e\u723e\u7cbe\u91c0\u5564\u9152";
Edit2->Text=UniToAnsi(Edit1->Text.c_str());

Friday, September 25, 2020

DLL to LIB

implib abcd.lib abcd.dll

Thursday, August 27, 2020

WideCanvasTextRect

WideCanvasTextRect
Example: WideCanvasTextRect(g->Canvas, Rect,Rect.Left+1,Rect.Top+5,wstring); WideCanvasTextRect(g->Canvas, Rect,
Rect.Left+1,Rect.Top+(Rect.Bottom-Rect.Top-g->Canvas->TextHeight(wstring))/2,wstring); 

void __fastcall TSOForm::gridDrawCell(TObject *Sender, int ACol, int ARow,
      TRect &Rect, TGridDrawState State)
{   
  TStringGrid *g=(TStringGrid*)Sender;;
	// save the unicode using UTF8Decode       
  WideString wstring=UTF8Decode(g->Cells[ACol][ARow]);
  WideCanvasTextRect(g->Canvas, Rect, Rect.Left+1, 
  Rect.Top+(Rect.Bottom-Rect.Top
  -g->Canvas->TextHeight(wstring))/2,wstring);         
}

Thursday, April 30, 2020

Fatal Error detected (LME1520)

Need to add a

#define DEBUGED 123

in the first line in MainForm

Wednesday, December 4, 2019

TAdvStringGrid Multiple Select Rows

Set MouseActions -> DisjuncRowSelect to true