Range over characters in Python

This is a great use for a custom generator: Python 3: def char_range(c1, c2): “””Generates the characters from `c1` to `c2`, inclusive.””” for c in range(ord(c1), ord(c2)+1): yield chr(c) then: for c in char_range(‘a’, ‘z’): print(c) Python 2: def char_range(c1, c2): “””Generates the characters from `c1` to `c2`, inclusive.””” for c in xrange(ord(c1), ord(c2)+1): yield … Read more

Character code of unknown character-character, e.g. square or question mark romb

Unicode has two symbols for unknown characters: □ (WHITE SQUARE, U+25A1) – Replaces a missing or unsupported Unicode character. � (REPLACEMENT CHARACTER, U+FFFD) – Replaces an invalid or unrecognizable character. Indicates a Unicode error. Sources Quora – What symbol is the square box shown for non-representable Unicode characters? FileFormat.Info – Unicode Character ‘WHITE SQUARE’ (U+25A1) … Read more

How can I find the index of a character in a string in Rust?

Although a little more convoluted than I would like, another solution is to use the Chars iterator and its position() function: “Program”.chars().position(|c| c == ‘g’).unwrap() find used in the accepted solution returns the byte offset and not necessarily the index of the character. It works fine with basic ASCII strings, such as the one in … Read more

What is the semicolon reserved for in URLs?

There is an explanation at the end of section 3.3. Aside from dot-segments in hierarchical paths, a path segment is considered opaque by the generic syntax. URI producing applications often use the reserved characters allowed in a segment to delimit scheme-specific or dereference-handler-specific subcomponents. For example, the semicolon (“;”) and equals (“=”) reserved characters are … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)