Skip to content

Commit cbc1780

Browse files
committed
📝 docs
1 parent 1c35f57 commit cbc1780

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

README.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,52 @@
11
lua-url-encode
22
==
33

4-
A URL encoder/decoder library for lua.
4+
A URL encoder/decoder library for lua with native extension.
5+
6+
This library aims to use within `application/x-www-form-urlencoded`.
7+
8+
Synopsis
9+
--
10+
11+
```lua
12+
local urlencode = require 'urlencode'
13+
14+
urlencode.encode_url("hello こんにちは") -- => hello+%E3%81%93%E3%82%93%E3%81%AB%E3%81%A1%E3%81%AF
15+
urlencode.decode_url("hello+%E3%81%93%E3%82%93%E3%81%AB%E3%81%A1%E3%81%AF") -- => hello こんにちは
16+
```
17+
18+
Functions
19+
--
20+
21+
### `encode_url(str)`
22+
23+
This function encodes the string as URL encoding. The string **MUST** be utf8.
24+
25+
### `decode_url(str)`
26+
27+
This function decodes the string as URL encoding. The string **MUST** be utf8.
28+
29+
Disclaimer
30+
--
31+
32+
This library only works certainly with utf8 string.
33+
34+
Benchmark
35+
--
36+
37+
Benchmark code is [here](./benchmark/bench.lua):
38+
39+
```
40+
pure lua: encode url system: 15.360 user: 0.100 total: 15.460 real: 16.125
41+
encodeurl: encode url system: 0.240 user: 0.040 total: 0.280 real: 0.312
42+
pure lua: decode url system: 10.160 user: 0.060 total: 10.220 real: 10.625
43+
encodeurl: decode url system: 0.260 user: 0.040 total: 0.300 real: 0.375
44+
```
45+
46+
Original code
47+
--
48+
49+
This library takes lots of code from [p5-url-encode-xs](https://github.com/chansen/p5-url-encode-xs).
550

651
License
752
--

0 commit comments

Comments
 (0)