String conversion is the act of converting data to and from character strings. It is a special case of type conversion and commonly used in programming to combine multiple data types into a string or when validating/storing user input.
Questions tagged [string-conversion]
377 questions
3459
votes
104 answers
How can I convert a string to boolean in JavaScript?
Can I convert a string representing a boolean value (e.g., 'true', 'false') into a intrinsic type in JavaScript?
I have a hidden form in HTML that is updated based upon a user's selection within a list. This form contains some fields which represent…

Kevin
- 7,856
- 11
- 35
- 40
806
votes
8 answers
How to change a string into uppercase?
How can I convert a string into uppercase in Python?
When I tried to research the problem, I found something about string.ascii_uppercase, but it couldn't solve the problem:
>>> s = 'sdsd'
>>> s.ascii_uppercase
Traceback (most recent call last):
…

gadss
- 21,687
- 41
- 104
- 154
272
votes
6 answers
What is the difference between parseInt(string) and Number(string) in JavaScript?
What is the difference between parseInt(string) and Number(string) in JavaScript?

DarkLightA
- 14,980
- 18
- 49
- 57
133
votes
8 answers
convert a JavaScript string variable to decimal/money
How can we convert a JavaScript string variable to decimal?
Is there a function such as:
parseInt(document.getElementById(amtid4).innerHTML)

Varada
- 16,026
- 13
- 48
- 69
122
votes
9 answers
conversion from string to JSON object Android
I am working on an Android application. In my app I have to convert a string to JSON Object, then parse the values. I checked for a solution in Stackoverflow and found similar issue here link
The solution is like this
…

sarath
- 3,181
- 7
- 36
- 58
94
votes
1 answer
How can I concatenate str and int objects?
If I try to do the following:
things = 5
print("You have " + things + " things.")
I get the following error in Python 3.x:
Traceback (most recent call last):
File "", line 1, in
TypeError: can only concatenate str (not "int") to…

Zero Piraeus
- 56,143
- 27
- 150
- 160
92
votes
3 answers
Python parse comma-separated number into int
How would I parse the string 1,000,000 (one million) into it's integer value in Python?

roryf
- 29,592
- 16
- 81
- 103
74
votes
6 answers
Converting & to & etc
I want to convert & to &, " to " etc.
Is there a function in c# that could do that without writing all the options manually?
user189370
54
votes
8 answers
How to convert array to a string using methods other than JSON?
What is a function in PHP used to convert array to string, other than using JSON?
I know there is a function that directly does like JSON. I just don't remember.

maniclorn
- 1,081
- 3
- 12
- 23
53
votes
5 answers
Template friendly string to numeric in C++
In C++ standard library there are functions to convert from string to numeric types:
stoi
stol
stoll
stoul
stoull
stof
stod
stold
but I find it tedious to use them in template code. Why there are no template functions something…

Mircea Ispas
- 20,260
- 32
- 123
- 211
47
votes
5 answers
What is the difference between Number(...) and parseFloat(...)
What is the difference between parseInt(string) and Number(string) in JavaScript has been asked previously.
But the answers basically focused on the radix and the ability of parseInt to take a string like "123htg" and turn it into 123.
What I am…

Naftali
- 144,921
- 39
- 244
- 303
36
votes
2 answers
Why does Resharper say, "Co-variant array conversion from string[] to object[] can cause run-time exception on write operation" with this code?
This code:
comboBoxMonth.Items.AddRange(UsageRptConstsAndUtils.months.ToArray());
public static List months = new List
{
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
…

B. Clay Shannon-B. Crow Raven
- 8,547
- 144
- 472
- 862
31
votes
2 answers
Convert string to float in Objective-C
How do I convert a string to a float in Objective-C?
I am trying to multiply a couple of strings I am getting back from JSON:
float subTotal = [[[[purchaseOrderItemsJSON objectAtIndex:i] objectAtIndex:j] objectForKey:@"Price"]…

Slee
- 27,498
- 52
- 145
- 243
28
votes
6 answers
How to convert a string to number
I can't figure it out how to convert this string 82144251 to a number.
Code:
var num = "82144251";
If I try the code below the .toFixed() function converts my number back to a string...
Question update:
I'm using the Google Apps Script editor and…

Valip
- 4,440
- 19
- 79
- 150
28
votes
4 answers
Convert Uint8Array into hex string equivalent in node.js
I am using node.js v4.5. Suppose I have this Uint8Array variable.
var uint8 = new Uint8Array(4);
uint8[0] = 0x1f;
uint8[1] = 0x2f;
uint8[2] = 0x3f;
uint8[3] = 0x4f;
This array can be of any length but let's assume the length is 4.
I would like to…
user6064424