Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
 While Sending Html Mails from my web application Recieved Mails contains Symbols like &ldquo,&rdquo, ‘ Check with another constructor for htmlView: ContentType mimeType = new System.Net.Mime.ContentType("text/html"); var htmlView = AlternateView.CreateAlternateViewFromString(bodyMessage, mimeType); Categories : Asp Net Mvc Regex to check special characters in the filename in an input directory/path I think something like the following provide a decent match for a Windows filename/directory structure: ^[A-Z]:(\[^\/:*?"<>|]+)+.w+$(Note that blacklist came from Windows Explorer after trying to enter in a bad character.) Example matches:$ grep -P '^[A-Z]:(\[^\/:*?"<>|]+)+.w+$' file_list.txt C:Sample File5.txt C:Program Files (x86)Windowsfile.exe C:Program FilesJon's folderfile.pdf C:my-file.txt C:5@^&[]{}!#i.txt.exe If you want to change that to a whitelist, modify accordingly:$ grep -P '^[A-Z]:(\[ws@-]+)+.w+$' file_list.txt C:Sample File5.txt C:my-file.txt Categories : Asp Net How to parse special characters using NSXMLPARSER - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string { catalogString = (NSMutableString *) [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; } this piece of code will remove ur special characters Categories : Iphone How to save special characters in parse.com with the REST API I just tried this in Terminal on OSX, without problems: curl -X POST -H "X-Parse-Application-Id: appID" -H "X-Parse-REST-API-Key: restKey" -H "Content-Type: application/json;" -d '{"testString":"é"}' https://api.parse.com/1/classes/TestObject The character encoding in the terminal was set to UTF-8. However, when changed to ISO-8859-1, I got the same error as you: {"code":107,"error":"invalid utf-8 string was provided"} So @ahoffer is probably right that you don't have utf-8 set as your terminal's character encoding. Categories : Parse Com JSON Parse fail with special characters If you want to include a " as data in a string in a JSON text, you have to escape it with a slash, otherwise it is treated as the closing delimiter for the string. ?": Categories : Javascript Send email in python using subprocess module You don't need to pass an argument list when you use shell=True you can just pass an argument string... command_line = 'mail -s "おお様からの天気予報" abc@gmail.com < foo' process = subprocess.Popen(command_line, shell=True) Or.. you can not use the shell to interpret your arguments and pass a list... command_line = 'mail -s "おお様からの天気予報" abc@gmail.com < foo' li = command_line.split() process = subprocess.Popen(li) But you can't pass an argument list and use the shell to interpret it. Based on the nature of your command, I would recommend passing a string to the shell to interpret. (the first option) Categories : Python Alternative to Python subprocess module in Google App Engine GAE only runs python code. Subprocess won't help you. You can't run bash scripts in GAE. You'll have to rewrite the bash script as a python program, at which point you probably just want to import and run your python script. Categories : Google App Engine Google Drive Parse error when uploading file with special unicode characters Try to download the latest version of the API (from https://code.google.com/p/google-api-dotnet-client/wiki/APIs#Drive_API). I changed line 122 in the Drive sample (instructions to download this sample are here), to Title = "字/漢字" and Title = "title with ç", and both of them worked for me. Categories : C# Find Python module filename Like this: >>> import re >>> re.__file__ '/usr/lib/python2.7/re.pyc' For packages that are not part of the Python core, you can also use __path__: >>> import requests >>> requests.__file__ '/usr/local/lib/python2.7/dist-packages/requests-1.1.0-py2.7.egg/requests/__init__.pyc' >>> requests.__path__ ['/usr/local/lib/python2.7/dist-packages/requests-1.1.0-py2.7.egg/requests'] Categories : Python Subprocess module from python fails to run bash commands like " | " This: echo Hello world | cut -d' ' -f1 … is not actually a command, it's a fragment of shell script. So you need to have the shell execute it. You can do this just by adding shell=True to the Popen constructor. The documentation explains how this works. It also explains better ways to do the same thing without the shell. For example: p1 = Popen(['echo', 'Hello', 'world'], stdout=PIPE) p2 = Popen(['cut', "-d' '", '-f1'], stdin=p1.stdout, stdout=PIPE) p1.stdout.close() test = p2.communicate()[0] Meanwhile, you almost never want to use split on a command line—and in fact, your example shows exactly why you don't want to: >>> cmd = "echo Hello world | cut -d' ' -f1" >>> cmd.split() ['echo', 'Hello', 'world', '|', 'cut', "-d'", "'", '-f1'] Notice that it spl Categories : Python converting special characters to hex in python >>> import binascii >>> a = 'aljsd;fkaj;' >>> binascii.hexlify(a) '616c6a73643b666b616a3b3b6b666a7177657234' If you get error, please post both code and error message here. Categories : Python How can I write special characters to a CSV in Python? You can't write Unicode to a CSV… but you can write bytes that happen to be UTF-8 (or Latin-1, or almost any other encoding*) encoding Unicode. The docs explicitly say this, and suggest how to deal with it: Note: This version of the csv module doesn’t support Unicode input. Also, there are currently some issues regarding ASCII NUL characters. Accordingly, all input should be UTF-8 or printable ASCII to be safe; see the examples in section Examples. These restrictions will be removed in the future. The Examples section shows how to deal with this, providing wrappers that let you read and write unicode objects, encoding/decoding UTF-8 automatically for you. If you're using a different charset (e.g., because you're planning to pass this to an Excel VBscript that requires a cp1252-en Categories : Python Python 3 Special characters escaping if x != (' ') or (' ') or (' ') should be if x not in (' ', ' ', ' ') or better: if not x.isspace() Your first code is evaluated as: if (x != (' ')) or ' ' or ' ' Notice the last values are evaluated as themselves! Only an empty string will evaluate False thus this condition will always pass Categories : Python Python: Special characters encoding There is no point in using codecs.open() if you don't use an encoding. Either use codecs.open() with an encoding specified for both reading and writing, or forgo it completely. Without an encoding, codecs.open() is an alias for just open(). Here you really do want to specify the codec of the file you are opening, to process Unicode values. You should also use unicode literal values when straying beyond ASCII characters; specify a source file encoding or use unicode escape codes for your data: # -*- coding: utf-8 -*- import os import codecs dirpath = u"C:\Users\user\path\to\textfiles" filenames = os.listdir(dirpath) with codecs.open(r'C:Usersuserpath ooutput.txt', 'w', encoding='utf8') as outfile: for fname in filenames: currentfile = os.path.join(dirpath, fname) wi Categories : Python how to read files with special characters in python You'll need to set the 'errors' keyword parameter to something other than the default strict. You can find a list of possibilities (for Python 3.3) here. The list is enumerated in the "codecs.register()" documentation. I'd start with the 'replace' option just so you can see what you're dealing with. Categories : Python What other special characters like " " can be used to prettify output in Python? On Windows you need to set terminal mode before using special characters. Lately I saw a crossplatform module to colorize output. https://pypi.python.org/pypi/colorama There are special chars to move the cursor. Also you may use ncurces to make text GUI. Categories : Python Python webpage source read with special characters Encoding is a PITA in Python3 for sure (and 2 in some cases as well). Try checking these links out, they might help you: Python - Encoding string - Swedish Letters Python3 - ascii/utf-8/iso-8859-1 can't decode byte 0xe5 (Swedish characters) http://docs.python.org/2/library/codecs.html Also it would be nice with the code for "So when I read the page content without specifying any encoding" My best guess is that your console doesn't use utf-8 (for instance, windows.. your # -*- coding: utf-8 -*- only tells Python what type of characters to find within the sourcecode, not the actual data the code is going to parse or analyze itself. For instance i write: # -*- coding: iso-8859-1 -*- import time # Här skriver jag ut tiden (Translation: Here, i print out the time) print(time.strftime(' Categories : Python Python encoding issue involving special characters You need to declare the encoding of the source file so Python can properly decode your string literals. You can do this with a special comment at the top of the file (first or second line). # coding: where is the encoding used when saving the file, for example utf-8. Categories : Python Using the subprocess or Command module of python for Windows command prompt Documentation says: cmd is actually run as: { cmd ; } 2>&1 And the function getstatusoutput() is available on UNIX not on Windows. Categories : Python Is it possible to comment out a line of PHP code containing special "special" characters? The reason why you are getting a strange output is because of the particular ?> in your regex. In this case, PHP is interpreting that as the end of the script, because the rest of the code is commented out. To answer your question directly, in this case, you cannot comment out that particular line of code without editing it. You would have to remove the ?> portion of the regex in order for the script to continue to run normally. Edit: Additionally, it would work if you encapsulated the comment in /* */ according to this post. However, because the regex has */ it is prematurely ending the block style comment, thus still breaking out of PHP mode and returning to HTML mode. Categories : PHP Python encoding: list to string having special characters and numbers in the list If you can specify the strings in your list as unicode, like: [u"Círculo", 23] [u"Triángulo", 25, 19, u"dos"] then this should work: u', '.join(unicode(x) for x in list_of_ints) Assuming you are running Python 2. Categories : Python Do not allow special characters except the allowed characters javascript regex You don't need to separate your individual characters by commas, nor do you need to wrap the only term in brackets. This should work: /[^~<>,"']/ note the carat (^ is not at the front, this has a special meaning when placed at the start of the [] block) Also you should use test() because you only want a boolean if-contains result /[^~<>,"']/.test(password) Categories : Javascript Converting Special Characters From Database to Normal Characters As I've worked a lot with "non-english" characters, several things are required for proper display and storage of those characters. In no particular order (as I don't know what charset is best suited for Persian, I'll use UTF-8, if it's different, you just use the one you need): Tell your browser what charset you are using, either by setting the proper header from PHP header('Content-type: text/html; charset=utf-8'); or set the meta tag in your html like so: In the database avoid mixing different collations and charsets in the columns/tables. I always set the database, the tables and the columns to utf8_general_ci which for my needs work all the time (languages like English, German, Serbian, Hungarian...). As J Categories : PHP Can't upload filename with special character to google drive REST Following the peleyal's commentary I solved my problem. I'm still using rest calls and not drive api, but I checked out the drive api source code and find out that they are using the HttpRequestMessage class. Changing my code from WebRequest to HttpRequestMessage solved the problem: var request = new HttpRequestMessage(HttpMethod.Post, uri); string strData = new JavaScriptSerializer().Serialize(jsonObject); var content = new StringContent(strData, Encoding.UTF8, "application/json"); content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json"); request.Content = content; Categories : C# How can i parse strings as the inputs to subprocess.Popen? You haven't said how your code fails, but it looks like you are trying to give MEncoder binary strings as command line parameters. http://www.mplayerhq.hu/DOCS/HTML/en/menc-feat-selecting-input.html says that you can give the filename in the command line, not the contents of a file. so to answer your question: with open('merged.flv', 'wb') as f: f.write(out1 + out2) ffmpeg_command2 = ["mencoder", "your", "other", "args", "merged.flv"] Categories : Python read subprocess output multi-byte characters one by one Wrap the file object in io.TextIOWrapper() to decode the pipe on the fly: import io reader = io.TextIOWrapper(p.stdout, encoding='utf8') while something: char = reader.read(1) Categories : Python Image download with arabic characters in filename (Arabic characters) Use the following web encoding tool and encode the Arabic URL and then hardcode to the url in the program and try http://meyerweb.com/eric/tools/dencoder/ Categories : Android What's the use of the filename parameter of ast.parse? It sets the co_filename attribute on the code object, which is used to display the filename in tracebacks. Besides that, it's not really significant what value you pass. >>> c = compile('raise Exception("spam")', 'eggs', 'exec') >>> eval(c) Traceback (most recent call last): File "", line 1, in File "eggs", line 1, in Exception: spam Categories : Python How can I parse a filename into components You are trying to use Perl-style regular expressions (specifically, the zero-width lookbehind assertion), which bash does not understand. Try the following: regex="(.*) S([0-9]{2})E([0-9]{2}) (.*).mp4" for filename in "Cop Rock S01E03 Happy Mudder's Day.mp4" ; do if [[ "$filename" =~ $regex ]]; then echo "Show:${BASH_REMATCH[1]}" echo "Season: ${BASH_REMATCH[2]}" echo "Episode:${BASH_REMATCH[3]}" echo "Title: ${BASH_REMATCH[4]}" fi done Categories : Regex Insert characters at end of filename (before extension)? Use basename and extname to extract the two parts you want: http://www.ruby-doc.org/core-2.0/File.html#method-c-basename http://www.ruby-doc.org/core-2.0/File.html#method-c-extname Categories : Ruby How to extract last 2 characters before the extension of a filename in bash? In order to pull something out of the middle of a string, you can use a substitution. The following works in bash: filename=myfileRE.txt echo "${filename/??./.}" This is matching the pattern "??." and replacing it with ".". It is similar to a perl or sed substitution, except it uses shell pattern matching instead of regex. Categories : Regex Jquery Filedrop: Russian characters in filename file name has to be urlencoded. add this function to filedrop's default options: var default_opts = { ... rename: function(name){ return encodeURIComponent(name); }, ... } "Каталог_2.xls" => "%D0%9A%D0%B0%D1%82%D0%B0%D0%BB%D0%BE%D0%B3_2.xls" Categories : HTML Removing last n characters from Unix Filename before the extension If this is a one time (or not very often) occasion, I would create a script with $ls > rename.sh$ vi rename.sh :%s/(.*)/mv 1 1/ (edit manually to remove all the XXXXX from the second file names) :x $source rename.sh If this need occurs frequently, I would need more insight into what XXXXX, YYY, and ZZZZZZZZZZZ are. Addendum Modify this to your liking: ls | sed "{s/(.*)(............).txt$/mv 12.txt 1.txt/}" | sh It transforms filenames by omitting 12 characters before .txt and passing the resulting mv command to a shell. Beware: If there are non-matching filenames, it executes the filename—and not a mv command. I omitted a way to select only matching filenames. Categories : Misc Filename in chinese shows as unicode characters I think this may be caused by one of those annoying interactions between the operating system and Emacs. Emacs doesn't seem to know how to interpret the file names, so let's try to help it by inserting this in your .emacs file. (setq default-buffer-file-coding-system 'utf-8-unix) (setq default-file-name-coding-system 'gb2312) (setq default-keyboard-coding-system 'utf-8-unix) (setq default-process-coding-system '(utf-8-unix . utf-8-unix)) You may need to try a different system instead of gb2312. Categories : Emacs gambio gx2 module implementation. Filename CONSTANT i found the solution, i think some newbie like me in gambio search it to. last point insert in database ALTER TABLE admin_access ADD myfile INT( 1 ) NOT NULL DEFAULT '0'; and update it to 1 for true Categories : PHP How to parse through file where filename stored in a variable What you have described could be a result of the following: log_file = 'archive_log' for line in log_file: print line (you print every character in log_file string) Seemingly you want this, however: log_file = 'archive_log' with open(log_file) as f: for line in f: print line Just remember, that the path is relative, and depends on where (from where) you run the code. It is better idea to use absolute paths. You can use eg. os.path.join() to get absolute path based on the name of the file (log_file, whose value in the example is 'archive_log') and path to the script file (__file__). EDIT: The following is the solution for Python 2.4 (Python 2.5 has support for with statement): log_file = 'archive_log' try: f = open(log_file) for line in f: print line Categories : Python How can i use special characters in IE 6 Fonts shipped with old versions of Windows where you can use IE 6 apparently do not cntain the character LATIN SMALL LETTER S WITH COMMA BELOW. Since it would be unrealistic to expect users to install new fonts just to see some special characters, the best shot is to use U+015F LATIN SMALL LETTER S WITH CEDILLA instead, either the character “ş” as such or as the character reference f; orş`. From the Unicode perspective, s with comma below and s with cedilla are glyph variants, but they have been defined as separate characters as requested by the Romanian standards institute, to allow the distinction to be made at the character level. However, even in Romania, this distinction is not made consistently at all, and s with cedilla has a much better font coverage. Categories : HTML Allow special characters in asp .net 3.5 Instead of passing data into QueryString you may pass data from one page to another by using Session as well.Set the Value in Session from page1 and get it easily on page2 and perform your search action easily. I don't know that this is the exact answer of your question but this is also a way to complete your task as well. Hope it works for you. Categories : Javascript Special characters or alt? The stuff inside the quotes is just literal content to be displayed, as per the psuedo-selector, prior to the element's content. As for more, it can be whatever, but it's literal: that is to say, you can't shove some HTML in there and expect it to be treated as such by the browser, it won't be. You can also use the :after pseudo element to do the obvious. From MDN re content: The content CSS property is used with the ::before and ::after pseudo-elements to generate content in an element. Objects inserted using the content property are anonymous replaced elements. Check out the link for more complex values, as I oversimplify here. Categories : HTML Special superscript characters I don't know if it possible to convert symbols to supersripts without creating mapping function for that, but you can just write it manually: update contact SET name='RACHᵀᴹ' where id='10782' sql fiddle demo Mapping function could be something like this: create or replace function superscript(data text) returns text as $$declare ss text[]; lt text[]; begin ss := '{ᴬ,ᴮ,ᴰ,ᴱ,ᴳ,ᴴ,ᴵ,ᴶ,ᴷ,ᴸ,ᴹ,ᴺ,ᴼ,ᴾ,ᴿ,ᵀ,ᵁ}'; lt := '{A,B,D,E,G,H,I,J,K,L,M,N,O,P,R,T,U}'; for i in 1..array_length(ss, 1) loop data := replace(data, lt[i], ss[i]); end loop; return data; end;$$ language plpgsql; sql fiddle demo Categories : SQL