Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1067421
  • 博文数量: 106
  • 博客积分: 9093
  • 博客等级: 中将
  • 技术积分: 2770
  • 用 户 组: 普通用户
  • 注册时间: 2006-06-01 17:22
文章分类

全部博文(106)

文章存档

2014年(1)

2012年(29)

2011年(32)

2010年(20)

2008年(24)

分类:

2010-12-21 15:28:23

我们可以用400提供的MI API函数CVTCH和CVTHC来实现字符和十六进制之间的互换。下面就是一个例子:
     H DFTACTGRP(*NO) BNDDIR('QC2LE')

     D cvtch           PR                  ExtProc('cvtch')
     D   target                   32767A   options(*varsize)
     D   src_chars                65534A   options(*varsize) const
     D   src_length                  10I 0 value

     D cvthc           PR                  ExtProc('cvthc')
     D   target                   65534A   options(*varsize)
     D   src_bits                 32767A   options(*varsize) const
     D   tgt_length                  10I 0 value

     D buf             S             25A
     D hexdump         S             50A
     D wait            s              1A

      /free

         // Create a "hex dump" of regular character data

         buf = 'Hello';

         cvthc( hexdump
              : buf
              : %len(%trimr(Buf)) * 2 );

         dsply hexdump ' ' wait;
         // Input the "hex dump" and convert to back to chars

         buf = *blanks;

         cvtch( buf
              : hexdump
              : %len(%trimr(hexdump)) );

         dsply buf ' ' wait;

         *inlr = *on;

      /end-free
阅读(2390) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~