special-characters

PHP ldap_add function to escape ldap special characters in DN syntax

社会主义新天地 提交于 2019-11-30 06:54:54
I'm trying to add some users to my Ldap DB but I get some errors (invalid dn syntax) when I use some special characters like ",.". I need a function that escape all characters. I try preg_quote but I get some errors in some cases. Thanks in advance Code: $user = 'Test , Name S.L'; if(!(ldap_add($ds, "cn=" . $user . ",".LDAP_DN_BASE, $info))) { include 'error_new_account.php'; } DaveRandom EDIT Jan 2013: added support for escaping leading/trailing spaces in DN strings, per RFC 4514 . Thanks to Eugenio for pointing out this issue. EDIT 2014: I added this function to PHP 5.6 . The code below is

Sending a string containing special characters through a TcpClient (byte[])

百般思念 提交于 2019-11-30 05:23:03
问题 I'm trying to send a string containing special characters through a TcpClient (byte[]). Here's an example: Client enters "amé" in a textbox Client converts string to byte[] using a certain encoding (I've tried all the predefined ones plus some like "iso-8859-1") Client sends byte[] through TCP Server receives and outputs the string reconverted with the same encoding (to a listbox) Edit : I forgot to mention that the resulting string was "am?". Edit-2 (as requested, here's some code): @DJKRAZE

Replace special character in htaccess

天大地大妈咪最大 提交于 2019-11-30 04:46:43
问题 I changed my forum from kunena to phpbb3. Problem is that my old forum (that is indexed in google) has special characters in urls. I want to keep my urls, so old link works with new forum - but only when special characters are replace with normal letters. I need to use htaccess to convert characters on the fly. for example ą => a ę => e ś => s ć => c so in words letters will be replaced like this po ś ciel ó wka => po s ciel o wka Can someone help me with that? p.s. sorry for bad English ;)

Python regex to convert non-ascii characters in a string to closest ascii equivalents

我怕爱的太早我们不能终老 提交于 2019-11-30 03:52:28
I'm seeking simple Python function that takes a string and returns a similar one but with all non-ascii characters converted to their closest ascii equivalent. For example, diacritics and whatnot should be dropped. I'm imagining there must be a pretty canonical way to do this and there are plenty of related stackoverflow questions but I'm not finding a simple answer so it seemed worth a separate question. Example input/output: "Étienne" -> "Etienne" Reading this question made me go looking for something better. https://pypi.python.org/pypi/Unidecode/0.04.1 Does exactly what you ask for. In

How to check if string has at least one letter, number and special character in php

a 夏天 提交于 2019-11-30 00:31:25
I am currently writing a small script that checks the contents of each string. I was wondering what the REGEX would be to make sure that a string has a letter (upper or lower), a digit, and a special character? Here is what I know so far (whcih isn't much): if(preg_match('/^[a-zA-Z0-9]+$/i', $string)): Help would be great! Thank You! The easiest (and probably best) way is to do three separate checks with preg_match : $containsLetter = preg_match('/[a-zA-Z]/', $string); $containsDigit = preg_match('/\d/', $string); $containsSpecial = preg_match('/[^a-zA-Z\d]/', $string); // $containsAll =

What's the difference between this characters? [duplicate]

末鹿安然 提交于 2019-11-29 23:09:03
问题 Possible Duplicate: What is the difference between \r and \n? I really would like to know what's the difference between \n , \r , \t , chr(13) , how they are used in a web application, in which OS, and so on. For example, can you confirm that windows uses \n\r for the newline, while of linux uses just \n right? It would be interesting to know these things. Thanks 回答1: \n - Line Feed - 0x0A - 10 decimal - LF \r - Carriage Return - 0X0D - 13 decimal - CR \t - tab - 0x09 - 9 decimal - ht

Non US characters in section headers for a UITableView

时间秒杀一切 提交于 2019-11-29 22:38:40
I have added a section list for a simple Core Data iPhone app. I followed this so question to create it - How to use the first character as a section name but my list also contain items starting with characters outside A-Z, specially Å,Ä and Ö used here in Sweden. The problem now is that when the table view shows the section list the three last characters are drawn wrong. See image below alt text http://img.skitch.com/20100130-jkt6e55pgyjwptgix1q8mwt7md.jpg It seems like my best option right now is to let those items be sorted under 'Z' if ([letter isEqual:@"Å"] || [letter isEqual:@"Ä"] ||

What does # mean in LISP

匆匆过客 提交于 2019-11-29 20:41:38
For example, #'functionname , is it necessary? #'functionname in Common Lisp Common Lisp and some other Lisp dialects have more than one namespace. Here the ones for functions and values are different. To get the function value of a name, we need to write: (function functionname) Since that is a bit long to write, there is a shorter notation: #'functionname To show the effect see this: (let ((foo 42)) (flet ((foo () 'bar)) (list foo (function foo) #'foo (foo)))) Above defines a local variable FOO and a local function FOO . The list statement returns the value of FOO , then the function value

Check NSString for special characters

走远了吗. 提交于 2019-11-29 20:18:01
I want to check an NSString for special characters, i.e. anything except a-z, A-Z and 0-9. I don't need to check how many special characters are present, or their positions, I just need to know whether a particular string contains any or not. If it does, then I want to be able to display "Error!", or something similar. For example, jHfd9982 is OK but asdJh992@ is not. Also, letters with accents, diacritics, etc. should not be allowed. How would I go about this? Thanks! Michael NSCharacterSet * set = [[NSCharacterSet characterSetWithCharactersInString:@

Deleting filenames that have space and special characters

╄→гoц情女王★ 提交于 2019-11-29 17:25:46
I have a large filelist of 7000+ files to delete from a Unix directory. I could have accomplished this using a while loop while read file do rm $file done < filelist or just cat filelist | xargs rm The challenge comes from deleting those files which have "Windows-like back slash \, colon : and spaces " in their filenames. Eg. C:\Sxxx Accr Vac 1111.txt N:\Lxxx\Dxxx_FOLDER\Mxxx\Mxxx_DOWNLOAD_TEXTFILE_PATH\000000_Mxxx_Bxxx-Pxxx-H.txt N:\Lxxx\Dxxx_FOLDER\Mxxx\Mxxx_DOWNLOAD_TEXTFILE_PATH\130607_Mxxx_Bxxx-Cxxx-L.txt N:\Lxxx\Dxxx_FOLDER\Mxxx\Mxxx_DOWNLOAD_TEXTFILE_PATH\140103_Mxxx_Xxxx-Pxx-H.txt To