Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


tross_Encode_String.m

Go to the documentation of this file.
00001 function [err,Sc] = tross_Encode_String (S)
00002 %
00003 %   [err,Se] = tross_Encode_String (S)
00004 %
00005 %Purpose:
00006 %   encodes a string a la Tom Ross for use in AFNI's HEADER
00007 %   
00008 %   
00009 %Input Parameters:
00010 %   S
00011 %   
00012 %   
00013 %Output Parameters:
00014 %   err : 0 No Problem
00015 %       : 1 Mucho Problems
00016 %   Se : the encoded version of S
00017 %   
00018 %      
00019 %Key Terms:
00020 %   
00021 %More Info :
00022 %   README.attributes
00023 %   
00024 %   To decode an encoded string (Se) you can run
00025 %   eval(['fprintf(1,''' Se ''');'])
00026 %
00027 %     Author : Ziad Saad
00028 %     Date : Wed Apr 11 09:28:10 PDT 2001
00029 %     LBC/NIMH/ National Institutes of Health, Bethesda Maryland
00030 
00031 
00032 %Define the function name for easy referencing
00033 FuncName = 'tross_Encode_String';
00034 
00035 %Debug Flag
00036 DBG = 1;
00037 
00038 %initailize return variables
00039 err = 1;
00040 
00041 %to find out the ascii number of special characters do
00042         %s = sprintf('\t'); double(s)
00043 CR = 13;
00044 LF = 10;
00045 QUOTE = 34; %double quote, that makes C go nuts
00046 TAB = 9;
00047 BEL = 7;
00048 VTAB = 11;
00049 BS = 8;
00050 
00051 Sd = double(S); %change S to ascii numbers
00052 N_Sd = length(Sd);
00053 Sc = '';
00054 for (i=1:1:N_Sd),
00055         switch Sd(i),
00056                 case CR,
00057                         Sc = sprintf('%s\\r', Sc);
00058                 case LF,
00059                         Sc = sprintf('%s\\n', Sc);
00060                 case QUOTE,
00061                         Sc = sprintf('%s\\"', Sc);
00062                 case TAB,
00063                         Sc = sprintf('%s\\t', Sc);
00064                 case BEL,
00065                         Sc = sprintf('%s\\a', Sc);
00066                 case VTAB,
00067                         Sc = sprintf('%s\\v', Sc);
00068                 case BS,
00069                         Sc = sprintf('%s\\b', Sc);
00070                 otherwise,
00071                         Sc = sprintf('%s%s', Sc, char(Sd(i)));
00072         end
00073 end
00074  
00075 
00076 err = 0;
00077 return;
00078 
 

Powered by Plone

This site conforms to the following standards: