cnCalc计算器论坛

 找回密码
 注册
搜索
查看: 3596|回复: 0

中文及长文件名支持库——修改版本移至Flash空间

[复制链接]
发表于 2014-8-14 01:43:36 | 显示全部楼层 |阅读模式
  1. #include "W25QXX.h" //modify v1.1

  2. #if !_USE_LFN || _CODE_PAGE != 936
  3. #error This file is not needed in current configuration. Remove from the project.
  4. #endif

  5. //modify v1.1
  6. #define __SPI_CC936   1
  7. #define UNI2OEM                                ((u32)2404)
  8. #define UNI2OEMEND                ((u32)89576)
  9. #define OEM2UNI                                ((u32)89577)
  10. #define OEM2UNIEND                ((u32)176749)

  11. #ifdef __SPI_CC936
  12. const WCHAR uni2oem;
  13. const WCHAR oem2uni;

  14. //add v1.1
  15. ULONG SizeOfTableuni2oem(void)
  16. {
  17.         return UNI2OEMEND-UNI2OEM;
  18. }

  19. ULONG SizeOfTableoem2uni(void)
  20. {
  21.         return OEM2UNIEND-OEM2UNI;
  22. }

  23. //modify v1.1
  24. WCHAR ff_convert (        /* Converted code, 0 means conversion error */
  25.         WCHAR        chr,        /* Character code to be converted */
  26.         UINT        dir                /* 0: Unicode to OEMCP, 1: OEMCP to Unicode */
  27. )
  28. {
  29.         //modify v1.1 const WCHAR *p;
  30.         WCHAR c;
  31.          int i, n, li, hi;
  32.         u32 p;//add v1.1
  33.   WCHAR tem[2];
  34.         if (chr < 0x80) {        /* ASCII */
  35.                 c = chr;
  36.         } else {
  37.                 if (dir) {                /* OEMCP to unicode */
  38.                         p = OEM2UNI;
  39.                         hi = SizeOfTableoem2uni() / 4 - 1;
  40.                 } else {                /* Unicode to OEMCP */
  41.                         p = UNI2OEM;
  42.                         hi = SizeOfTableuni2oem() / 4 - 1;
  43.                 }
  44.                 li = 0;
  45.                 for (n = 16; n; n--) {
  46.                         i = li + (hi - li) / 2;
  47.                         W25Q128_BufferRead((u8 *)tem,p+(i * 2),2);
  48.                         if (chr == (*(u16*)tem) ) break;
  49.                         if (chr > (*(u16*)tem) )
  50.                                 li = i;
  51.                         else
  52.                                 hi = i;
  53.                 }
  54.           W25Q128_BufferRead((u8 *)tem, p+(i * 2 + 1),2);
  55.                 c = n ? (*(u16*)tem) : 0;
  56.         }
  57.         return c;
  58. }
复制代码
cc936.c.txt (708.77 KB, 下载次数: 27)
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|cnCalc计算器论坛

GMT+8, 2024-4-25 00:38 , Processed in 0.052445 second(s), 21 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表