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.

7119 questions
982
votes
10 answers

What characters do I need to escape in XML documents?

What characters must be escaped in XML documents, or where could I find such a list?
Julius A
  • 33,082
  • 26
  • 68
  • 92
687
votes
23 answers

Repeat a string in JavaScript a number of times

In Perl I can repeat a character multiple times using the syntax: $a = "a" x 10; // results in "aaaaaaaaaa" Is there a simple way to accomplish this in Javascript? I can obviously use a function, but I was wondering if there was any built in…
Steve
  • 45,586
  • 30
  • 89
  • 135
586
votes
12 answers

What characters are valid for JavaScript variable names?

Which characters can be used for naming a JavaScript variable? I want to create a small "extension library" for my non-JavaScript users here at work (who all seem to be squeamish when it comes to the language). I love how jQuery and Prototype have…
Richard Clayton
  • 6,882
  • 3
  • 20
  • 19
456
votes
46 answers

Get nth character of a string in Swift programming language

How can I get the nth character of a string? I tried bracket([]) accessor with no luck. var string = "Hello, world!" var firstChar = string[0] // Throws error ERROR: 'subscript' is unavailable: cannot subscript String with an Int, see the…
Mohsen
  • 58,878
  • 30
  • 149
  • 175
432
votes
18 answers

How can I remove a character from a string using JavaScript?

I am so close to getting this, but it just isn't right. All I would like to do is remove the character r from a string. The problem is, there is more than one instance of r in the string. However, it is always the character at index 4 (so the 5th…
user1293504
  • 4,361
  • 2
  • 13
  • 6
416
votes
8 answers

Replace a character at a specific index in a string?

I'm trying to replace a character at a specific index in a string. What I'm doing is: String myName = "domanokz"; myName.charAt(4) = 'x'; This gives an error. Is there any method to do this?
dpp
  • 25,478
  • 28
  • 95
  • 150
398
votes
15 answers

What is the easiest/best/most correct way to iterate through the characters of a string in Java?

StringTokenizer? Convert the String to a char[] and iterate over that? Something else?
Paul Wicks
  • 55,730
  • 52
  • 115
  • 144
329
votes
13 answers

Remove all occurrences of char from string

I can use this: String str = "TextX Xto modifyX"; str = str.replace('X','');//that does not work because there is no such character '' Is there a way to remove all occurrences of character X from a String in Java? I tried this and is not what I…
evilReiko
  • 16,552
  • 21
  • 76
  • 90
287
votes
17 answers

Is there an upside down caret character?

I have to maintain a large number of classic ASP pages, many of which have tabular data with no sort capabilities at all. Whatever order the original developer used in the database query is what you're stuck with. I want to to tack on some basic…
Joel Coehoorn
  • 362,140
  • 107
  • 528
  • 764
263
votes
10 answers

How can I escape square brackets in a LIKE clause?

I am trying to filter items with a stored procedure using like. The column is a varchar(15). The items I am trying to filter have square brackets in the name. For example: WC[R]S123456. If I do a LIKE 'WC[R]S123456' it will not return anything. I…
Travis
  • 3,029
  • 2
  • 17
  • 11
263
votes
10 answers

Java String remove all non numeric characters but keep the decimal separator

Trying to remove all letters and characters that are not 0-9 and a period. I'm using Character.isDigit() but it also removes decimal, how can I also keep the decimal?
DRing
  • 6,085
  • 5
  • 21
  • 34
260
votes
22 answers

Remove last character from string. Swift language

How can I remove last character from String variable using Swift? Can't find it in documentation. Here is full example: var expression = "45+22" expression = expression.substringToIndex(countElements(expression) - 1)
Konstantin Cherkasov
  • 2,893
  • 2
  • 14
  • 21
256
votes
7 answers

What is the difference between a string and a byte string?

I am working with a library which returns a byte string and I need to convert this to a string. Although I'm not sure what the difference is - if any.
Sheldon
  • 7,678
  • 17
  • 55
  • 89
255
votes
10 answers

For every character in string

How would I do a for loop on every character in string in C++?
Jack Wilsdon
  • 5,963
  • 8
  • 41
  • 81
244
votes
10 answers

What is a vertical tab?

What was the original historical use of the vertical tab character (\v in the C language, ASCII 11)? Did it ever have a key on a keyboard? How did someone generate it? Is there any language or system still in use today where the vertical tab…
dmazzoni
  • 12,008
  • 4
  • 35
  • 34
1
2 3
99 100