{ Snipperize } /string
Snippets about string
Compressing Strings
When talking about compression, we usually think about files, such as ZIP archives. It is possible to compress long strings in PHP, without involving any archive files. We were able to achive almost 50% size reduction. Also the functions gzencode() and gzdecode() achive similar results, by using a different compression algorithm.
PHP / string, compress, gzip, gzencode, gzdecode, gzcompress, gzuncompress / by ThePeppersStudio (72 days, 5.29 hours ago)
in-place stream formatting
void f( std::string const & ); void g( const char* ); f( make_string() << "Say hi" ); // works ok g( make_string() << "Bye" ); // kills the application g( (make_string() << "Hi again").c_str() ); // ok again std::string temporary is alive until g() returns
C++ / make_string, string, cstring, iostream / by ThePeppersStudio (142 days, 1.65 hours ago)
Fastest vs Easiest way to read a full file into a std::string.
Fastest vs Easiest way to read a full file into a std::string.
C++ / fastest, easiest, iostream, string, file / by ThePeppersStudio (142 days, 1.75 hours ago)
Reverse a string including unicode combining characters
Example: >>> ucode = ''.join( chr(int(n, 16)) for n in ['61', '73', '20dd', '64', '66', '305'] ) >>> ucoderev = ureverse(ucode) >>> ['%x' % ord(char) for char in ucoderev] ['66', '305', '64', '73', '20dd', '61'] >>>
Python / unicode, string, reverse / by ThePeppersStudio (213 days, 6.99 hours ago)
Trim Function for String in C++
The main() is just for testing the function, let's see how it went. $ gcc -Wall -o go trim.c $ ./go s = 'srikanth s' empty = '' newline = '' double_newline = '' single_char = 's' This function doesn't create a new char[] for the trimmed string, it modifies the original. Let me know if you've got an optimized version than this, I'll be interested to learn.
C++ / trim, string / by ThePeppersStudio (227 days, 3.63 hours ago)
Convert String To ASCII
避免多语言编码问题
PHP / convert, string, ascii / by ThePeppersStudio (247 days, 2.20 hours ago)
Format string as machine compatible key
This snippet converts a "dirty" string that may contain special characters into a machine compatible nice looking string. That function works fine for creating urls or ID keys.
PHP / url, string, convert / by ThePeppersStudio (286 days, 10.35 hours ago)
MD5-based block cipher
MD5-based block cipher (MDC-like), which works in 128bit CFB mode. It is very useful to encrypt secret data before transfer it over the network.
PHP / encrypt, string, cipher, md5 / by ThePeppersStudio (286 days, 10.39 hours ago)
正则删除重复字符串
利用正则表达式删除重复字符串
PHP / preg_replace, 正则表达式, 重复, repleat, string / by ThePeppersStudio (293 days, 0.11 hours ago)
Convert Hex to Str/Convert Str to Hex
convert a string to it's hex representation and back
PHP / convert, hex, string / by ThePeppersStudio (329 days, 1.33 hours ago)
- Home
- New Snippet
- Languages
-

