新闻中心

EEPW首页 > 嵌入式系统 > 设计应用 > 嵌入式系统多语言文本解决方案

嵌入式系统多语言文本解决方案

作者:时间:2012-03-12来源:网络收藏

  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; //字符串长度,不包括''

  WORD * pContent; //字符串内容,以''结尾

  } GUISTRING;

  //结束与字符串相关的数据结构的定义

  #define GUI_STRING_STRUCT

  #endif

  /***

linux操作系统文章专题:linux操作系统详解(linux不再难懂)


评论


相关推荐

技术专区

关闭