00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "xmlencodeattr.h"
00019 QString encodeAttr( const QString& str )
00020 {
00021 QString tmp( str );
00022 uint len = tmp.length();
00023 uint i = 0;
00024 while ( i < len ) {
00025 if ( tmp[(int)i] == '<' ) {
00026 tmp.replace( i, 1, "<" );
00027 len += 3;
00028 i += 4;
00029 } else if ( tmp[(int)i] == '"' ) {
00030 tmp.replace( i, 1, """ );
00031 len += 5;
00032 i += 6;
00033 } else if ( tmp[(int)i] == '&' ) {
00034 tmp.replace( i, 1, "&" );
00035 len += 4;
00036 i += 5;
00037 } else if ( tmp[(int)i] == '>' ) {
00038 tmp.replace( i, 1, ">" );
00039 len += 3;
00040 i += 4;
00041 } else {
00042 ++i;
00043 }
00044 }
00045
00046 return tmp;
00047 }
00048