注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

Simon

 
 
 

日志

 
 

symbian 字符串描述符格式化format输出转换  

2011-03-03 19:29:15|  分类: Symbian C++ |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
  1. Buf16<256> tgt;  
  2. ...  
  3. _LIT16(KFormat1,"[%b %c %d %o %u %x]");  
  4. tgt.Format(KFormat1,65,65,65,65,65,65);//generates:  
  5. ...                                  //[1000001 A 65 101 65 41]  
  6. ...  
  7. _LIT16(KFormat2,"[%04x]");           // pad char="0", field width=4  
  8. tgt.Format(KFormat2,65);             //generates:  
  9. ...                                  //[0041]  
  10. ...  
  11. _LIT16(KFormat3,"[%4x]");            // pad char=default, field width=4  
  12. tgt.Format(KFormat3,65);             //generates:  
  13. ...                                  //[  41]  
  14. ...                                  // Note use of blanks as default pad chars.  
  15. ...  
  16. _LIT16(KFormat4,"[%*x]");            // fixed field width, taken from the arguments list  
  17. tgt.Format(KFormat4,4,65);           //generates:  
  18. ...                                  //[  41]  
  19. ...  
  20. ...  
  21. _LIT16(KFormat5,"[%+$4d.00 %S]");    // pad char="$", field width=4, right aligned  
  22. _LIT16(KOver,"over");                  
  23. tgt.Format(KFormat5,65,&KOver);      //generates:  
  24. ...                                  //[$$65.00 over]  
  25. ...  
  26. _LIT16(KFormat6,"[%+4d.00 %S]");     // pad char=default, field width=4  
  27. tgt.Format(KFormat6,65,&KOver);      //generates:  
  28. ...                                  //[  65.00 over]  
  29. ...                                  //   note no pad char specified, defaults  
  30. ...                                  //   to blank  
  31. ...  
  32. _LIT16(KFormat7,"[% 4d.00 %S]");     // pad char=" ", field width=4, alignment=default  
  33. tgt.Format(KFormat7,65,&KOver);      //generates:  
  34. ...                                  //[  65.00 over]  
  35. ...                                  //   note default right hand alignment and  
  36. ...                                  //   blank pad char  
  37. ...  
  38. _LIT16(KFormat8,"[%+0*S]");          // right aligned, pad char="0", fixed field width  
  39. _LIT16(KFred,"fred");                  
  40. tgt.Format(KFormat8,10,&KFred);      //generates:  
  41. ...                                  //[000000fred]  
  42. ...                                  // Note: 10 characters generated  
  43. ...  
  44. _LIT16(KFormat9,"[%=*6x]");          // centre aligned, pad char taken from arguments list, field width=6  
  45. tgt.Format(KFormat9,'*',65);         //generates:  
  46. ...                                  //[**41**]  
  47. ...  
  48. _LIT16(KFormat10,"[%+**d]");         // right aligned, pad char and field width taken from arguments list  
  49. tgt.Format(KFormat10,'.',10,(-65));  //generates:  
  50. ...                                  //[.......-65]  
  51. ...  
  52. _LIT16(KFormat11,"[%-A4p]");         // left aligned, field width=4, pad char="A"  
  53. tgt.Format(KFormat11,65);            //generates  
  54. ...                                  //[AAAA]  
  55. ...                                  //   and makes no use of the argument list  
  56. ...  
  57. _LIT16(KFormat12,"[%m]");            //generates:  
  58. tgt.Format(KFormat12,4660);          //   the char '['  
  59. ...                                  //   followed by a byte with 0x12  
  60. ...                                  //   followed by a byte with 0x34  
  61. ...                                  //   followed by the char ']'  
  62. _LIT16(KFormat13,"[%M]")  
  63. tgt.Format(KFormat13,4660);          //generates:  
  64. ...                                  //   the char '['  
  65. ...                                  //   followed by a byte with 0x00  
  66. ...                                  //   followed by a byte with 0x00  
  67. ...                                  //   followed by a byte with 0x12  
  68. ...                                  //   followed by a byte with 0x34  
  69. ...                                  //   followed by the char ']'  
  70. ...  
  71. _LIT16(KFormat14,"[%w]");            //generates:  
  72. tgt.Format(KFormat14,4660);          //   the char '['  
  73. ...                                  //   followed by a byte with 0x34  
  74. ...                                  //   followed by a byte with 0x12  
  75. ...                                  //   followed by the char ']'  
  76. ..  
  77. _LIT16(KFormat15,"[%w]");            //generates:  
  78. tgt.Format(KFormat15,4660);          //   the char '['  
  79. ...                                  //   followed by a byte with 0x34  
  80. ...                                  //   followed by a byte with 0x12  
  81. ...                                  //   followed by a byte with 0x00  
  82. ...                                  //   followed by a byte with 0x00  
  83. ...                                  //   followed by the char ']'  
  84. ...  
  85. _LIT16(KFormat16,"[%6.2e]");           
  86. tgt.Format(KFormat16,3.4555);        //generates:  
  87. ...                                  //[3.46E+00]  
  88. _LIT16(KFormat17,"[%6.2f]");           
  89. tgt.Format(KFormat17,3.4555);        //generates:  
  90. ...                                  //[  3.46]  
  91. _LIT16(KFormat18,"[%6.2g]");           
  92. tgt.Format(KFormat18,3.4555);        //generates:  
  93.                                      //[3.4555]  
  94. ...  
  95. // Variable  argument positions  
  96. _LIT16(KFormat19,"[%d %d]");          // implicit ordering  
  97. tgt.Format(KFormat19,9,5);           // generates:  
  98. ...                                  // [9 5]  
  99. ...  
  100. _LIT16(KFormat20,"[%$2$d %$1$d]");    // explicit ordering  
  101. tgt.Format(KFormat20,9,5);           // generates:  
  102. ...                                  // [5 9]  
  103. ...  
  104. _LIT16(KFormat21,"[%$1$d %$2$d]");    // explicit ordering (same as the implicit order)  
  105. tgt.Format(KFormat21,9,5);           // generates:  
  106. ...                                  // [9 5]  
  107.   
  108. // Using argument blocks (a many-to-one mapping between arguments and conversion specifiers)  
  109. _LIT16(KFormat22,"[%0*d %d %d]");     // implicit ordering  
  110. tgt.Format(KFormat22,3,9,5,12);      // generates:  
  111. ...                                  // [009 5 12]  
  112. ...  
  113. _LIT16(KFormat23,"[%$2$d %$1$0*d %d]"); // mixed explicit and implicit ordering  
  114. tgt.Format(KFormat23,3,9,5,12);      // generates:  
  115. ...                                  // [5 009 12]  
  116. ...                                    
  117. _LIT16(KFormat24,"[%$3$d %$1$0*d %$2$d]"); // explicit ordering  
  118. tgt.Format(KFormat24,3,9,5,12);      // generates:  
  119. ...                                  // [12 009 5]  
  评论这张
 
阅读(773)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018