嵌入式系統多語言文本解決方案
strFile = TXT_FILE_POLISH;
break;
default:
return NULL;
}
//打開配置文件并檢查其格式
if ((fd = open(strFile, O_RDONLY)) == -1)
{
return NULL;
}
if (read(fd, fh, 16) != 16)
{
close(fd);
return NULL;
}
if (fh.lFileType != 0x4746432E || fh.lVersionNum != 0x32303156)
{
close(fd);
return NULL;
}
for (iOff = fh.lMapOffset; iOff fh.lDataOffset; iOff += 8)
{
if (read(fd, map, 8) != 8)
{
close(fd);
return NULL;
}
if (map.wTextIndex == lIndex)
{
break;
}
}
if (iOff >= fh.lDataOffset)
{
close(fd);
return NULL;
}
//根據找到的文本映射來讀取文本內容
if (!(pBuf = GuiMemAlloc(map.wTextSize + 2)))
{
close(fd);
return NULL;
}
lseek(fd, fh.lDataOffset + map.lTextOffset, SEEK_SET);
if (read(fd, pBuf, map.wTextSize) != map.wTextSize)
{
GuiMemFree(pBuf);
close(fd);
return NULL;
}
pBuf[map.wTextSize >> 1] = 0;
//建立字符串對象
pTxt = CreateStringDirect(pBuf);
GuiMemFree(pBuf);
close(fd);
return pTxt;
}
//定義與字符串相關的數據結構
#ifndef GUI_STRING_STRUCT
typedef struct _string
{
WORD wWidth; //字符串寬度,字符串輸出時的總點陣寬度
WORD wLength; //字符串長度,不包括' 主站蜘蛛池模板: 左权县| 武乡县| 阳信县| 广水市| 桃江县| 疏勒县| 综艺| 含山县| 太湖县| 定日县| 莎车县| 新竹市| 鸡西市| 蒲江县| 丹江口市| 青海省| 大新县| 禹城市| 三门县| 乡宁县| 盘山县| 林西县| 墨竹工卡县| 吉木萨尔县| 托里县| 昆山市| 宜兰市| 黄浦区| 从江县| 尼勒克县| 鹿邑县| 韶关市| 信宜市| 赤水市| 内丘县| 固安县| 门源| 灵武市| 通渭县| 宜宾市| 怀集县|