新聞中心

EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 嵌入式系統(tǒng)多語(yǔ)言文本解決方案

嵌入式系統(tǒng)多語(yǔ)言文本解決方案

作者: 時(shí)間:2012-03-12 來(lái)源:網(wǎng)絡(luò) 收藏

  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;

  }

  //在映射區(qū)內(nèi)查找匹配的索引

  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ù)找到的映射來(lái)讀取文本內(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;

  //建立字符串對(duì)象

  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; //字符串寬度,字符串輸出時(shí)的總點(diǎn)陣寬度

  WORD wLength; //字符串長(zhǎng)度,不包括'