Questions tagged [character]

Refers to a symbol that represents a letter or number. Also, the bit pattern used to represent such a symbol.

In computer and machine-based telecommunications terminology, a character is a unit of information that roughly corresponds to a grapheme, grapheme-like unit, or symbol, such as in an alphabet or syllabary in the written form of a natural language. Examples of characters include letters, numerical digits, and common punctuation marks (such as '.' or '-'). The concept also includes control characters, which do not correspond to symbols in a particular natural language, but rather to other bits of information used to process text in one or more languages. Computers and communication equipment represent characters using a character encoding that assigns each character to something — an integer quantity represented by a sequence of bits, typically — that can be stored or transmitted through a network. Two examples of popular encodings are ASCII and the UTF-8 encoding for Unicode.

7762 questions
90
votes
8 answers

In Python, how to check if a string only contains certain characters?

In Python, how to check if a string only contains certain characters? I need to check a string containing only a..z, 0..9, and . (period) and no other character. I could iterate over each character and check the character is a..z or 0..9, or . but…
X10
  • 17,155
  • 7
  • 30
  • 28
89
votes
6 answers

What's the opposite of a nbsp?

A   character is a space which doesn't allow for line breaking.

lorem ipsum here are some words and so on

| lorem ipsum | | here are some words and so | | on | What's the opposite…
nickf
  • 537,072
  • 198
  • 649
  • 721
89
votes
7 answers

Invisible characters - ASCII

Are there any invisible characters? I have checked Google for invisible characters and ended up with many answers but I'm not sure about those. Can someone on Stack Overflow tell me more about this? Also I have checked a profile on Facebook and…
DonOfDen
  • 3,968
  • 11
  • 62
  • 112
86
votes
15 answers

What's the simplest way to convert from a single character String to an ASCII value in Swift?

I just want to get the ASCII value of a single char string in Swift. This is how I'm currently doing it: var singleChar = "a" println(singleChar.unicodeScalars[singleChar.unicodeScalars.startIndex].value) //prints: 97 This is so ugly though. There…
DavidNorman
  • 1,421
  • 1
  • 17
  • 22
85
votes
3 answers

What are the Java semantics of an escaped number in a character literal, e.g. '\15' ?

Please explain what, exactly, happens when the following sections of code are executed: int a='\15'; System.out.println(a); this prints out 13; int a='\25'; System.out.println(a); this prints out 21; int a='\100'; System.out.println(a); this…
VAr
  • 2,551
  • 1
  • 27
  • 40
83
votes
8 answers

How to determine if a String has non-alphanumeric characters?

I need a method that can tell me if a String has non alphanumeric characters. For example if the String is "abcdef?" or "abcdefà", the method must return true.
lugeno
  • 1,055
  • 3
  • 10
  • 18
80
votes
14 answers

How can restrict my EditText input to some special character like backslash(/),tild(~) etc by soft keyboard in android programmatically

I am developing an application for keyboard, but i am geting an issue. I want to restrict/block some special character from soft keyboard in EditText in android programmatically. So, Is there any way I can restrict any special character input in…
Jagdish
  • 2,418
  • 4
  • 25
  • 51
76
votes
9 answers

What's the HTML character entity for the # sign?

What's the HTML character entity for the # sign? I've looked around for "pound" (which keeps returning the currency), and "hash" and "number", but what I try doesn't seem to turn into the right character.
chimerical
  • 5,883
  • 8
  • 31
  • 37
73
votes
7 answers

Get character position in alphabet

I'm 90% sure there is a built in function that does this. I need to find the position of a character in an alphabet. So the character "b" is position 1 (counting from 0), etc. Does anyone know what the function is called? What I'm trying to do is to…
qwerty
  • 973
  • 2
  • 9
  • 10
73
votes
3 answers

What is the proper HTML entity for the "x" in a dimension?

Is the proper HTML entity for giving dimensions ×? I want to be semantically correct, but that begs the question, is listing a dimension as 2" x 3" even semantic? If the x represents "by", would I use the letter x or ×? In my code I've been…
Nick
  • 2,872
  • 3
  • 34
  • 43
72
votes
6 answers

Change the next N characters in VIM

Say I have the following line: |add_test() (| == cursor position) And want to replace the 'add' with a 'del'. del|_test() I can either press X three times and then press i to insert and type del. What I want is something like 3c or 3r to…
MrB
  • 2,155
  • 7
  • 27
  • 33
70
votes
6 answers

How to decode character pressed from jQuery's keydown()'s event handler

I need to figure out which character was typed into a text field from within the handler that is called by jQuery's keydown function. key.which gives me only the keycode, but I need to figure out which ASCII character key represents. How do I do…
Chetan
  • 46,743
  • 31
  • 106
  • 145
70
votes
7 answers

How can I get a Unicode character's code?

Let's say I have this: char registered = '®'; or an umlaut, or whatever unicode character. How could I get its code?
Geo
  • 93,257
  • 117
  • 344
  • 520
69
votes
6 answers

Converting characters to integers in Java

Can someone please explain to me what is going on here: char c = '+'; int i = (int)c; System.out.println("i: " + i + " ch: " + Character.getNumericValue(c)); This prints i: 43 ch:-1. Does that mean I have to rely on primitive conversions to convert…
JRR
  • 6,014
  • 6
  • 39
  • 59
68
votes
4 answers

How many characters can you store with 1 byte?

1 byte = 8 bits So, does this mean 1 byte can only hold one character? E.g.: "16" uses 2 bytes , "9" uses 1 byte , "a" uses 1 byte, "b" uses 1 byte and if tiny int has range of 0-255, does this mean it can be stored with 255 char? what is…
Abhi Adr
  • 1,264
  • 2
  • 11
  • 27