Skip to content
Browse files

[feature] libbase: Encodings simple generator of encode/decode function

  • Loading branch information...
1 parent 280b13a commit c65e357588da4152941aad7e0afcfb859ba9d47a @BourgerieQuentin BourgerieQuentin committed Apr 17, 2012
Showing with 9 additions and 1 deletion.
  1. +4 −0 libbase/encodings.ml
  2. +5 −1 libbase/encodings.mli
View
4 libbase/encodings.ml
@@ -129,6 +129,10 @@ let encode_aws_uri = (fun s -> encode_chars_filter Charf.is_awsf pc_encode s)
let decode_uri_component = decode_string [ pchxhx ]
+let pc_encode_string is_char s =
+ encode_chars_filter (function '%' -> false | c -> is_char c) pc_encode s
+let pc_decode_string = decode_string [ pchxhx ]
+
let escaped1 = [ "'","'"; "&","&"; ]
let escaped2 = (* ' redefined here for revert operation *)
[ ">","&gt;"; "<","&lt;"; "\"","&quot;"; "'","&apos;";
View
6 libbase/encodings.mli
@@ -1,5 +1,5 @@
(*
- Copyright © 2011 MLstate
+ Copyright © 2011, 2012 MLstate
This file is part of OPA.
@@ -24,6 +24,10 @@ val http_unencode : string -> string
(** Generic string encoding functions. *)
val encode_chars : ?hint:(int -> int) -> (char -> string) -> string -> string
+val pc_encode_string : (char -> bool) -> string -> string
+
+val pc_decode_string : string -> string
+
val encode_list_to_map : (char * string) list -> string array
val encode_uri_component : string -> string
val decode_uri_component : string -> string

0 comments on commit c65e357

Please sign in to comment.
Something went wrong with that request. Please try again.