2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
6 | Copyright (c) 1997-2010 The PHP Group |
7 +----------------------------------------------------------------------+
8 | This source file is subject to version 3.01 of the PHP license, |
9 | that is bundled with this package in the file LICENSE, and is |
10 | available through the world-wide-web at the following url: |
11 | http://www.php.net/license/3_01.txt |
12 | If you did not receive a copy of the PHP license and are unable to |
13 | obtain it through the world-wide-web, please send a note to |
14 | license@php.net so we can mail you a copy immediately. |
15 +----------------------------------------------------------------------+
18 #ifndef incl_HPHP_EXT_STRING_H_
19 #define incl_HPHP_EXT_STRING_H_
21 #include "hphp/zend/zend-html.h"
22 #include "hphp/runtime/base/base-includes.h"
23 #include "hphp/runtime/base/zend-string.h"
24 #include "hphp/runtime/base/zend-printf.h"
25 #include "hphp/runtime/base/bstring.h"
27 #include "hphp/runtime/ext/ext_class.h"
30 ///////////////////////////////////////////////////////////////////////////////
31 // transformations and manipulations
33 String
f_addcslashes(const String
& str
, const String
& charlist
);
34 String
f_stripcslashes(const String
& str
);
35 String
f_addslashes(const String
& str
);
36 String
f_stripslashes(const String
& str
);
37 String
f_bin2hex(const String
& str
);
38 Variant
f_hex2bin(const String
& str
);
39 String
f_nl2br(const String
& str
);
40 String
f_quotemeta(const String
& str
);
41 String
f_str_shuffle(const String
& str
);
42 String
f_strrev(const String
& str
);
43 String
f_strtolower(String str
);
44 String
f_strtoupper(String str
);
45 String
f_ucfirst(String str
);
46 String
f_lcfirst(String str
);
47 String
f_ucwords(String str
);
48 String
f_strip_tags(const String
& str
, const String
& allowable_tags
= "");
49 String
f_trim(String str
, const String
& charlist
= k_HPHP_TRIM_CHARLIST
);
50 String
f_ltrim(String str
, const String
& charlist
= k_HPHP_TRIM_CHARLIST
);
51 String
f_rtrim(String str
, const String
& charlist
= k_HPHP_TRIM_CHARLIST
);
52 String
f_chop(String str
, const String
& charlist
= k_HPHP_TRIM_CHARLIST
);
53 Variant
f_explode(const String
& delimiter
, const String
& str
, int limit
= 0x7FFFFFFF);
55 String
f_implode(CVarRef arg1
, CVarRef arg2
= null_variant
);
57 String
f_join(CVarRef glue
, CVarRef pieces
= null_variant
);
58 Variant
f_str_split(const String
& str
, int split_length
= 1);
59 Variant
f_chunk_split(const String
& body
, int chunklen
= 76,
60 const String
& end
= "\r\n");
62 Variant
f_strtok(const String
& str
, CVarRef token
= null_variant
);
64 Variant
f_str_replace(CVarRef search
, CVarRef replace
, CVarRef subject
,
65 VRefParam count
= uninit_null());
66 Variant
f_str_ireplace(CVarRef search
, CVarRef replace
, CVarRef subject
,
67 VRefParam count
= uninit_null());
68 Variant
f_substr_replace(CVarRef str
, CVarRef replacement
, CVarRef start
,
69 CVarRef length
= 0x7FFFFFFF);
71 Variant
f_substr(const String
& str
, int start
, int length
= 0x7FFFFFFF);
72 String
f_str_pad(const String
& input
, int pad_length
, const String
& pad_string
= " ",
73 int pad_type
= k_STR_PAD_RIGHT
);
74 String
f_str_repeat(const String
& input
, int multiplier
);
76 ///////////////////////////////////////////////////////////////////////////////
79 String
f_html_entity_decode(const String
& str
, int quote_style
= k_ENT_COMPAT
,
80 const String
& charset
= "ISO-8859-1");
81 String
f_htmlentities(const String
& str
, int quote_style
= k_ENT_COMPAT
,
82 const String
& charset
= "ISO-8859-1",
83 bool double_encode
= true);
84 String
f_htmlspecialchars_decode(const String
& str
,
85 int quote_style
= k_ENT_COMPAT
);
86 String
f_htmlspecialchars(const String
& str
, int quote_style
= k_ENT_COMPAT
,
87 const String
& charset
= "ISO-8859-1",
88 bool double_encode
= true);
89 String
f_fb_htmlspecialchars(const String
& str
, int quote_style
= k_ENT_COMPAT
,
90 const String
& charset
= "ISO-8859-1",
91 CArrRef extra
= empty_array
);
92 String
f_quoted_printable_encode(const String
& str
);
93 String
f_quoted_printable_decode(const String
& str
);
94 Variant
f_convert_uudecode(const String
& data
);
95 Variant
f_convert_uuencode(const String
& data
);
96 String
f_str_rot13(const String
& str
);
97 int64_t f_crc32(const String
& str
);
98 String
f_crypt(const String
& str
, const String
& salt
= "");
99 String
f_md5(const String
& str
, bool raw_output
= false);
100 String
f_sha1(const String
& str
, bool raw_output
= false);
101 Variant
f_strtr(const String
& str
, CVarRef from
, CVarRef to
= null_variant
);
103 String
f_convert_cyr_string(const String
& str
, const String
& from
, const String
& to
);
105 Array
f_get_html_translation_table(int table
= 0,
106 int quote_style
= k_ENT_COMPAT
);
108 String
f_hebrev(const String
& hebrew_text
, int max_chars_per_line
= 0);
110 String
f_hebrevc(const String
& hebrew_text
, int max_chars_per_line
= 0);
112 Variant
f_setlocale(int _argc
, int category
, CVarRef locale
, CArrRef _argv
= null_array
);
113 Array
f_localeconv();
115 String
f_nl_langinfo(int item
);
117 ///////////////////////////////////////////////////////////////////////////////
120 Variant
f_printf(int _argc
, const String
& format
, CArrRef _argv
= null_array
);
121 Variant
f_vprintf(const String
& format
, CArrRef args
);
122 Variant
f_sprintf(int _argc
, const String
& format
, CArrRef _argv
= null_array
);
123 Variant
f_vsprintf(const String
& format
, CArrRef args
);
125 Variant
f_sscanf(int _argc
, const String
& str
, const String
& format
, CArrRef _argv
= null_array
);
127 String
f_chr(int64_t ascii
);
128 int64_t f_ord(const String
& str
);
129 Variant
f_money_format(const String
& format
, double number
);
130 String
f_number_format(double number
, int decimals
= 0, CVarRef dec_point
= ".",
131 CVarRef thousands_sep
= ",");
133 ///////////////////////////////////////////////////////////////////////////////
136 int64_t f_strcmp(const String
& str1
, const String
& str2
);
137 Variant
f_strncmp(const String
& str1
, const String
& str2
, int len
);
138 int64_t f_strnatcmp(const String
& str1
, const String
& str2
);
139 int64_t f_strcasecmp(const String
& str1
, const String
& str2
);
140 Variant
f_strncasecmp(const String
& str1
, const String
& str2
, int len
);
141 int64_t f_strnatcasecmp(const String
& str1
, const String
& str2
);
142 int64_t f_strcoll(const String
& str1
, const String
& str2
);
144 Variant
f_substr_compare(const String
& main_str
, const String
& str
, int offset
,
145 int length
= INT_MAX
, bool case_insensitivity
= false);
147 Variant
f_strrchr(const String
& haystack
, CVarRef needle
);
148 Variant
f_strstr(const String
& haystack
, CVarRef needle
, bool before_needle
= false);
149 Variant
f_stristr(const String
& haystack
, CVarRef needle
);
150 Variant
f_strpbrk(const String
& haystack
, const String
& char_list
);
152 Variant
f_strchr(const String
& haystack
, CVarRef needle
);
154 Variant
f_strpos(const String
& haystack
, CVarRef needle
, int offset
= 0);
155 Variant
f_stripos(const String
& haystack
, CVarRef needle
, int offset
= 0);
156 Variant
f_strrpos(const String
& haystack
, CVarRef needle
, int offset
= 0);
157 Variant
f_strripos(const String
& haystack
, CVarRef needle
, int offset
= 0);
159 Variant
f_substr_count(const String
& haystack
, const String
& needle
, int offset
= 0,
160 int length
= 0x7FFFFFFF);
161 Variant
f_strspn(const String
& str1
, const String
& str2
, int start
= 0,
162 int length
= 0x7FFFFFFF);
163 Variant
f_strcspn(const String
& str1
, const String
& str2
, int start
= 0,
164 int length
= 0x7FFFFFFF);
166 Variant
f_strlen(CVarRef vstr
);
168 Variant
f_count_chars(const String
& str
, int64_t mode
= 0);
170 Variant
f_str_word_count(const String
& str
, int64_t format
= 0, const String
& charlist
= "");
172 int64_t f_levenshtein(const String
& str1
, const String
& str2
, int cost_ins
= 1,
173 int cost_rep
= 1, int cost_del
= 1);
174 int64_t f_similar_text(const String
& first
, const String
& second
, VRefParam percent
= uninit_null());
175 Variant
f_soundex(const String
& str
);
176 Variant
f_metaphone(const String
& str
, int phones
= 0);
178 ///////////////////////////////////////////////////////////////////////////////
181 void f_parse_str(const String
& str
, VRefParam arr
= uninit_null());
183 ///////////////////////////////////////////////////////////////////////////////