hexdump.m

来自「toolbox of BVQX, This is the access betw」· M 代码 · 共 60 行

M
60
字号
function hd = hexdump(av)
% hexdump  - dump hexadecimal values into string
%
% FORMAT:       hd = hexdump(asciivals)
%
% Input fields:
%
%       asciivals   1xN double or char array
%
% Output fields:
%
%       hd          hexdumped string
%
% See also bitdump

% Version:  v0.5c
% Build:    6120415
% Date:     Dec-04 2006, 3:15 PM CET
% Author:   Jochen Weber, Brain Innovation, B.V., Maastricht, NL
% URL/Info: http://wiki.brainvoyager.com/BVQXtools

% argument check
if nargin < 1 || ...
   (~ischar(av) && ...
    ~isa(av, 'double'))
    error( ...
        'BVQXtools:BadArgument', ...
        'Missing or wrong argument.' ...
    );
end

% get lenth and size
l = length(av);
p = 1;

% prepare output
hd = '';

% iterate until end
while (p < l)

    % get stretch
    pa = av(p:min(p+15, l));

    % print into string
    hd = [hd sprintf('%08X:  %-50s %-16s\n', p - 1, ...
        sprintf('%02X ', double(pa)), ...
        saveascii(pa))];

    % go on
    p = p + 16;
end


% internal function to remove ascii characters
function sa = saveascii(av)
    av(av < 32 | av > 127) = 46;
    sa = sprintf('%c', av);
% end of function sa = saveascii(av)

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?