special-characters

How to escape special characters like ' in sqlite in android

独自空忆成欢 提交于 2019-11-26 12:20:42
I have a function which is executing a query on a table in SQLite database. I declare a constant: public static final String CANADA_HISTORY = "Canada's History"; . This is stored in a String variable let's say difficulty , I have one query: Cursor c = mDb.rawQuery("select * from Questions_answers where CHAPTERS = '"+difficulty+"'" , null); It is throwing an exception near the apostrophe. Logcat output: I/Database( 1170): sqlite returned: error code = 1, msg = near "s": syntax error D/AndroidRuntime( 1170): Shutting down VM W/dalvikvm( 1170): threadid=1: thread exiting with uncaught exception

Allowed characters in filename

我们两清 提交于 2019-11-26 12:20:07
Where can I find a list of allowed characters in filenames, depending on the operating system? (e.g. on Linux, the character : is allowed in filenames, but not on Windows) You should start with the Wikipedia Filename page. It has a decent-sized table ( Comparison of filename limitations ), listing the reserved characters for quite a lot of file systems. It also has a plethora of other information about each file system, including reserved file names such as CON under MS-DOS. I mention that only because I was bitten by that once when I shortened an include file from const.h to con.h and spent

How do I add a bullet symbol in TextView?

丶灬走出姿态 提交于 2019-11-26 11:49:56
问题 I have a TextView and I want to add a bullet symbol in my text through XML. Is it possible? 回答1: You have to use the right character encoding to accomplish this effect. You could try with • Update Just to clarify: use setText("\u2022 Bullet"); to add the bullet programmatically. 0x2022 = 8226 回答2: This worked for me: <string name="text_with_bullet">Text with a \u2022</string> 回答3: Copy paste: •. I've done it with other weird characters, such as ◄ and ►. Edit: here's an example. The two Button

Objective-C: How to replace HTML entities? [duplicate]

隐身守侯 提交于 2019-11-26 11:14:48
问题 This question already has answers here : Objective C HTML escape/unescape (14 answers) Closed 6 years ago . I\'m getting text from Internet and it contains html entities (i.e. ó = ó). I want to show this text into a custom iPhone cell. I\'ve tried to use a UIWebView into my custom cell but I prefer to use a multiline UILabel. The problem is I can\'t find any way of replacing these HTML entities. 回答1: Check out my NSString category for HTML. Here are the methods available: - (NSString *

Which characters need to be escaped when using Bash?

左心房为你撑大大i 提交于 2019-11-26 10:02:06
Is there any comprehensive list of characters that need to be escaped in Bash? Can it be checked just with sed ? In particular, I was checking whether % needs to be escaped or not. I tried echo "h%h" | sed 's/%/i/g' and worked fine, without escaping % . Does it mean % does not need to be escaped? Was this a good way to check the necessity? And more general: are they the same characters to escape in shell and bash ? There are two easy and safe rules which work not only in sh but also bash . 1. Put the whole string in single quotes This works for all chars except single quote itself. To escape

Get Character value from KeyCode in JavaScript… then trim

一笑奈何 提交于 2019-11-26 08:54:28
问题 This is what I have now: $(\"input\").bind(\"keydown\",function(e){ var value = this.value + String.fromCharCode(e.keyCode); } If the e.keyCode may not be an ASCII character ( Alt , backspace , del , arrows , etc.)... I would now need to trim these values from value somehow (preferably programmatically - not with lookup tables). I\'m using jQuery. I must use the keydown event. keyPress doesn\'t activate for certain keys I need to capture ( Esc , del , backspace , etc.). I cannot use

The “backspace” escape character &#39;\b&#39;: unexpected behavior?

拈花ヽ惹草 提交于 2019-11-26 08:50:47
问题 So I\'m finally reading through K&R, and I learned something within the first few pages, that there is a backspace escape character, \\b . So I go to test it out, and there is some very odd behavior: #include <stdio.h> main () { printf(\"hello worl\\b\\bd\\n\"); } The output is hello wodl Can anyone explain this? 回答1: Your result will vary depending on what kind of terminal or console program you're on, but yes, on most \b is a nondestructive backspace. It moves the cursor backward, but doesn

php mail special characters utf8

﹥>﹥吖頭↗ 提交于 2019-11-26 08:30:51
问题 I have the following script: <?php $subject = \"Testmail — Special Characters\"; $msg = \"Hi there,\\n\\nthis isn’t something easy.\\n\\nI haven’t thought that it’s that complicated!\"; mail($to,$subject,$msg,$from.\"\\nContent-Type: text/plain; charset=UTF-8\\nContent-Transfer-Encoding: 8bit\\n\"); ?> In the e-mail: Subject: Testmail ? Special Characters Body: Hi there, this isn?t something easy. I haven?t thought that it?s that complicated! I tried a lot of things, but I have no ideas

Is a colon `:` safe for friendly-URL use?

守給你的承諾、 提交于 2019-11-26 08:01:32
问题 We are designing a URL system that will specify application sections as words separated by slashes. Specifically, this is in GWT, so the relevant parts of the URL will be in the hash (which will be interpreted by a controller layer on the client-side): http://site/gwturl#section1/section2 Some sections may need additional attributes, which we\'d like to specify with a : , so that the section parts of the URL are unambiguous. The code would split first on / , then on : , like this: http://site

How to escape literal percent sign when NO_BACKSLASH_ESCAPES option is enabled?

谁说胖子不能爱 提交于 2019-11-26 07:40:53
问题 My company runs MySQL in NO_BACKSLASH_ESCAPES mode. How can I escape a literal % or _ in a LIKE query in this mode? The standard way is \\% , but that doesn\'t work in this mode. Example: a column has the following values: 5% off , 50% off . The following query works in standard mode but not in NO_BACKSLASH_ESCAPES mode: SELECT * FROM mytable WHERE mycol LIKE \'5\\% off\' 回答1: you need escape select * from mytable where mycol like '5\% off' escape '\'; For a version that works regardless of