ObjFW  Check-in [4fa95c938d]

Overview
Comment:Rename -[url{De,En}codedString] to -[stringByURL{De,En}coding].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 4fa95c938d2efef461af270b55cac3dfb0e31233e255980e3d28004e8ac3b2e0
User & Date: js on 2009-06-05 18:30:15
Other Links: manifest | tags
Context
2009-06-06
14:10
Add OFFile singletons for stdin, stdout and stderr. check-in: f285996b91 user: js tags: trunk
2009-06-05
18:30
Rename -[url{De,En}codedString] to -[stringByURL{De,En}coding]. check-in: 4fa95c938d user: js tags: trunk
2009-06-03
19:38
Don't add PLUGIN_LDFLAGS to LDFLAGS, the buildsys handles this. check-in: 7f048e87dc user: js tags: trunk
Changes

Modified src/OFURLEncoding.h from [372c3e5fe1] to [b1c227a687].

19
20
21
22
23
24
25
26

27
28
29
30
31
32
33

34
19
20
21
22
23
24
25

26
27
28
29
30
31
32

33
34







-
+






-
+

 */
@interface OFString (OFURLEncoding)
/**
 * Encodes a string for use in a URL.
 *
 * \return A new, autoreleased string
 */
- (OFString*)urlEncodedString;
- (OFString*)stringByURLEncoding;

/**
 * Decodes a string used in a URL.
 *
 * \return A new, autoreleased string
 */
- (OFString*)urlDecodedString;
- (OFString*)stringByURLDecoding;
@end

Modified src/OFURLEncoding.m from [573e813f26] to [74051613f4].

19
20
21
22
23
24
25
26

27
28
29
30
31
32
33
19
20
21
22
23
24
25

26
27
28
29
30
31
32
33







-
+







#import "OFURLEncoding.h"
#import "OFExceptions.h"

/* Reference for static linking */
int _OFURLEncoding_reference;

@implementation OFString (OFURLEncoding)
- (OFString*)urlEncodedString
- (OFString*)stringByURLEncoding
{
	const char *s;
	char *ret_c;
	size_t i;
	OFString *ret;

	s = string;
59
60
61
62
63
64
65
66

67
68
69
70
71
72
73
59
60
61
62
63
64
65

66
67
68
69
70
71
72
73







-
+







	} @finally {
		free(ret_c);
	}

	return ret;
}

- (OFString*)urlDecodedString
- (OFString*)stringByURLDecoding
{
	const char *s;
	char *ret_c, c;
	size_t i;
	int st;
	OFString *ret;

Modified tests/OFString/OFString.m from [8579a7043b] to [6c5bfadd7f].

105
106
107
108
109
110
111
112
113
114
115





116
117
118
119
120
121
122
105
106
107
108
109
110
111




112
113
114
115
116
117
118
119
120
121
122
123







-
-
-
-
+
+
+
+
+







	CHECK([[a objectAtIndex: j++] isEqual: @"foo"])
	CHECK([[a objectAtIndex: j++] isEqual: @"bar"])
	CHECK([[a objectAtIndex: j++] isEqual: @""])
	CHECK([[a objectAtIndex: j++] isEqual: @"baz"])
	CHECK([[a objectAtIndex: j++] isEqual: @""])
	CHECK([[a objectAtIndex: j++] isEqual: @""])

	CHECK([[@"foo\"ba'_$" urlEncodedString] isEqual: @"foo%22ba%27_%24"])
	CHECK([[@"foo%20bar%22%24" urlDecodedString] isEqual: @"foo bar\"$"])
	CHECK_EXCEPT([@"foo%bar" urlDecodedString], OFInvalidEncodingException)
	CHECK_EXCEPT([@"foo%FFbar" urlDecodedString],
	CHECK([[@"foo\"ba'_$" stringByURLEncoding] isEqual: @"foo%22ba%27_%24"])
	CHECK([[@"foo%20bar%22%24" stringByURLDecoding] isEqual: @"foo bar\"$"])
	CHECK_EXCEPT([@"foo%bar" stringByURLDecoding],
	    OFInvalidEncodingException)
	CHECK_EXCEPT([@"foo%FFbar" stringByURLDecoding],
	    OFInvalidEncodingException)

	s1 = [@"asd fo asd fofo asd" mutableCopy];
	[s1 replaceOccurrencesOfString: @"fo"
			    withString: @"foo"];
	CHECK([s1 isEqual: @"asd foo asd foofoo asd"])
	s1 = [@"XX" mutableCopy];