character

What's the difference between Character.toUpperCase() and Character.toTitleCase()

好久不见. 提交于 2019-12-09 15:07:10
问题 I was refactoring some of my old code and then I found out that I'd used Character.toTitleCase() method at some point and couldn't help myself wondering if Character.toUpperCase() would be better. I read their descriptions and didn't see any basic difference: toUpperCase Converts the character argument to uppercase using case mapping information from the UnicodeData file. Note that Character.isUpperCase(Character.toUpperCase(ch)) does not always return true for some ranges of characters,

Determining and removing invisible characters from a string in PHP (%E2%80%8E)

一世执手 提交于 2019-12-09 11:59:45
问题 I have strings in PHP which I read from a database. The strings are URLs and at first glance they look good, but there seems to be some weird character at the end. In the address bar of the browser, the string '%E2%80%8E' gets appended to the URL, which breaks the URL. I found this post on stripping the left-to-right-mark from a string in PHP and it seems related to my problem, but the solution does not work for me because my characters seem to be something else. So how can I determine which

How do I find out how many bytes a character has?

有些话、适合烂在心里 提交于 2019-12-09 08:29:45
问题 I was wondering how do I find out how many bytes does a character have? 回答1: If you want to find out how many UTF-8 bytes a letter in a PHP string has then: print strlen(mb_substr($string, 0, 1, "utf-8")); strlen() returns the raw byte length, while mb_substr() returns a "character" according to the charset/encoding. In this example from position 0 . 回答2: ASCII is 7 bits. Most other languages use 8 bits (1 byte). Many eastern languages (Chinese, Japanese) use 16 bits (2 bytes). Unicode is

Don't allow a specific use of characters

廉价感情. 提交于 2019-12-09 04:03:09
问题 I bumped into a problem, i hope someone can help me out :) I got a TextBox, and i want to limit users, so that they can't write multiple \ one after another. I'm using it for folders. For instance: C\temp\test\ Now I want to prevent input like: C\temp\test\\\ I've tried searching around for this problem, but I couldn't find anything like this, so I hope it's possible :) I don't really have any code to show, but here's the code for my TextBox: private void textBox1_TextChanged(object sender,

Find the position of the first occurrence of any number in string

▼魔方 西西 提交于 2019-12-09 02:57:48
问题 Can someone help me with algorithm for finding the position of the first occurrence of any number in a string? The code I found on the web does not work: function my_offset($text){ preg_match('/^[^\-]*-\D*/', $text, $m); return strlen($m[0]); } echo my_offset('[HorribleSubs] Bleach - 311 [720p].mkv'); 回答1: function my_ofset($text){ preg_match('/^\D*(?=\d)/', $text, $m); return isset($m[0]) ? strlen($m[0]) : false; } should work for this. The original code required a - to come before the first

Remove all characters from string which are not on whitelist

早过忘川 提交于 2019-12-09 02:44:37
问题 I am trying to write java code which would remove all unwanted characters and let there be only whitelisted ones. Example: String[] whitelist = {"a", "b", "c"..."z", "0"..."9", "[", "]",...} I want there only letters (lower and uppercase) and numbers + some next characters I would add. Then I would start for() cycle for every character in the string, and replace it with empty string if it isn't on whitelist. But that isn't good solution. Maybe it could be done somehow using pattern (regex)?

Get the string up to a specific character

拥有回忆 提交于 2019-12-09 02:05:22
问题 var hello = "hello, how are you?" var hello2 = "hello, how are you @tom?" i want to delete every letter behind the @ sign. result should be var hello2 = "hello, how are you @tom?" -> hello2.trimmed() print(hello2.trimmed()) -> "hello, how are you" Update As i want to use it to link multiple users and replace the space behind @sign with the correct name, I always need the reference to the latest occurrence of the @sign to replace it. text3 = "hey i love you @Tom @Marcus @Peter" Example what

How to count character occurrences using SIMD

爷,独闯天下 提交于 2019-12-08 22:36:54
问题 I am given a array of lowercase characters (up to 1.5Gb) and a character c. And I want to find how many occurrences are of the character c using AVX instructions. unsigned long long char_count_AVX2(char * vector, int size, char c){ unsigned long long sum =0; int i, j; const int con=3; __m256i ans[con]; for(i=0; i<con; i++) ans[i]=_mm256_setzero_si256(); __m256i Zer=_mm256_setzero_si256(); __m256i C=_mm256_set1_epi8(c); __m256i Assos=_mm256_set1_epi8(0x01); __m256i FF=_mm256_set1_epi8(0xFF); _

Breaking down a Hangul syllable into letters (jamo)

元气小坏坏 提交于 2019-12-08 18:23:26
I'm working on a program that deals with Korean sentences and I need a way to break down a syllable, or block, into its letters. For those who don't know Hangul, a syllable is composed of 2-4 letters (jamo), creating thousands of different combinations. What I'd like to do is break down those syllables into the letters that form it. I was able to get the first letter by comparing its Unicode value to the associated letter in that range, i.e. a syllable that starts with x letter is in y range. However, I'm at a loss for finding the rest of the letters. This is a table containing the Unicode

Differences between character() and “” in R

风流意气都作罢 提交于 2019-12-08 17:37:19
问题 Just realize the output is different: > y="" > y [1] "" > y=character() > y character(0) However, nothing odd has happened. And I am not clear about these differences, and want to keep this problem(if any) clear in mind. So, thank you for helping. 回答1: You are confusing the length (number of elements) of a vector with the number of characters in a string: Consider these three things: > x=c("","") > y="" > z=character() Their length is the number of elements in the vector: > length(x) [1] 2 >