author | kergoth <kergoth> | 2003-08-09 16:24:58 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2003-08-09 16:24:58 (UTC) |
commit | e16d333ec2e8509fc665921ca106c25325bae9e0 (patch) (unidiff) | |
tree | 9e9068190a15bc9b2a52ab33b40881128f732c0e /noncore/apps/tableviewer/xmlencodeattr.cpp | |
parent | 1c58d1407f9584fedcdae390a04e2b37e5853361 (diff) | |
download | opie-e16d333ec2e8509fc665921ca106c25325bae9e0.zip opie-e16d333ec2e8509fc665921ca106c25325bae9e0.tar.gz opie-e16d333ec2e8509fc665921ca106c25325bae9e0.tar.bz2 |
Merge from BRANCH_1_0
Diffstat (limited to 'noncore/apps/tableviewer/xmlencodeattr.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/tableviewer/xmlencodeattr.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/noncore/apps/tableviewer/xmlencodeattr.cpp b/noncore/apps/tableviewer/xmlencodeattr.cpp new file mode 100644 index 0000000..de264f7 --- a/dev/null +++ b/noncore/apps/tableviewer/xmlencodeattr.cpp | |||
@@ -0,0 +1,48 @@ | |||
1 | /* | ||
2 | * xmlencodeattr.h | ||
3 | * | ||
4 | * copyright : (c) 2003 by Joseph Wenninger | ||
5 | * except for a small modification it's identical to qdom.cpp:encodeAttr | ||
6 | * email : jowenn@handhelds.org | ||
7 | * | ||
8 | */ | ||
9 | /*************************************************************************** | ||
10 | * * | ||
11 | * This program is free software; you can redistribute it and/or modify * | ||
12 | * it under the terms of the GNU General Public License as published by * | ||
13 | * the Free Software Foundation; either version 2 of the License, or * | ||
14 | * (at your option) any later version. * | ||
15 | * * | ||
16 | ***************************************************************************/ | ||
17 | |||
18 | #include "xmlencodeattr.h" | ||
19 | QString encodeAttr( const QString& str ) | ||
20 | { | ||
21 | QString tmp( str ); | ||
22 | uint len = tmp.length(); | ||
23 | uint i = 0; | ||
24 | while ( i < len ) { | ||
25 | if ( tmp[(int)i] == '<' ) { | ||
26 | tmp.replace( i, 1, "<" ); | ||
27 | len += 3; | ||
28 | i += 4; | ||
29 | } else if ( tmp[(int)i] == '"' ) { | ||
30 | tmp.replace( i, 1, """ ); | ||
31 | len += 5; | ||
32 | i += 6; | ||
33 | } else if ( tmp[(int)i] == '&' ) { | ||
34 | tmp.replace( i, 1, "&" ); | ||
35 | len += 4; | ||
36 | i += 5; | ||
37 | } else if ( tmp[(int)i] == '>' ) { | ||
38 | tmp.replace( i, 1, ">" ); | ||
39 | len += 3; | ||
40 | i += 4; | ||
41 | } else { | ||
42 | ++i; | ||
43 | } | ||
44 | } | ||
45 | |||
46 | return tmp; | ||
47 | } | ||
48 | |||