嵌入式系統(tǒng)多語言文本解決方案
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;
}
//根據(jù)找到的文本映射來讀取文本內(nèi)容
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;
}
//定義與字符串相關(guān)的數(shù)據(jù)結(jié)構(gòu)
#ifndef GUI_STRING_STRUCT
typedef struct _string
{
WORD wWidth; //字符串寬度,字符串輸出時的總點陣寬度
WORD wLength; //字符串長度,不包括' 主站蜘蛛池模板: 阿城市| 沙坪坝区| 新营市| 上犹县| 尚志市| 杂多县| 托克托县| 崇阳县| 宽甸| 克山县| 涟源市| 福贡县| 楚雄市| 凤翔县| 正宁县| 皋兰县| 麻栗坡县| 渝北区| 上蔡县| 宝应县| 朝阳市| 侯马市| 股票| 德钦县| 宿州市| 伊吾县| 绵阳市| 哈尔滨市| 白水县| 五河县| 英德市| 张北县| 北流市| 阿鲁科尔沁旗| 巴林右旗| 南漳县| 中方县| 博白县| 武功县| 华蓥市| 芦山县|