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
1104
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
  • 38,062
  • 26
  • 74
  • 96
842
votes
24 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
  • 53,375
  • 33
  • 96
  • 141
639
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
  • 7,452
  • 3
  • 23
  • 19
517
votes
22 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
  • 5,211
  • 2
  • 15
  • 6
511
votes
48 answers

Get nth character of a string in Swift

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
  • 64,437
  • 34
  • 159
  • 186
470
votes
9 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?
kazinix
  • 28,987
  • 33
  • 107
  • 157
470
votes
17 answers

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

Some ways to iterate through the characters of a string in Java are: Using StringTokenizer? Converting the String to a char[] and iterating over that. What is the easiest/best/most correct way to iterate?
Paul Wicks
  • 62,960
  • 55
  • 119
  • 146
375
votes
9 answers

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

I am working with a library which returns a "byte string" (bytes) and I need to convert this to a string. Is there actually a difference between those two things? How are they related, and how can I do the conversion?
Sheldon
  • 9,639
  • 20
  • 59
  • 96
349
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
  • 19,501
  • 24
  • 86
  • 102
332
votes
18 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
  • 399,467
  • 113
  • 570
  • 794
298
votes
11 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,825
  • 6
  • 29
  • 45
297
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,389
  • 2
  • 19
  • 11
295
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,866
  • 4
  • 38
  • 34
294
votes
23 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
  • 3,243
  • 2
  • 18
  • 22
293
votes
10 answers

For every character in string

How would I do a for loop on every character in string in C++?
Jack Wilsdon
  • 6,706
  • 11
  • 44
  • 87
1
2 3
99 100