The Stack Overflow podcast is back! Listen to an interview with our new CEO.
3 replaced http://stackoverflow.com/ with https://stackoverflow.com/
source | link

Sometimes, we need to stuff an integer ID into a string, for example when generating HTML form <select> items.

Calling int.ToString() can result in digits outside the range [0-9] in certain cultures. For that reason, you need to specify the invariant culture in culture-spanning apps (e.g. int.ToString(CultureInfo.InvariantCulture)).

Is it worth taking care and doing that even if it is known that the application will only run in one specific western culture (e.g. German)? It seems to be the "correct" thing to do. Or is that effort not well spent?

Update: It appears that integer formatting is almost immune to cultureinteger formatting is almost immune to culture anyway. My assumption was wrong but I'll keep the text for context.

Sometimes, we need to stuff an integer ID into a string, for example when generating HTML form <select> items.

Calling int.ToString() can result in digits outside the range [0-9] in certain cultures. For that reason, you need to specify the invariant culture in culture-spanning apps (e.g. int.ToString(CultureInfo.InvariantCulture)).

Is it worth taking care and doing that even if it is known that the application will only run in one specific western culture (e.g. German)? It seems to be the "correct" thing to do. Or is that effort not well spent?

Update: It appears that integer formatting is almost immune to culture anyway. My assumption was wrong but I'll keep the text for context.

Sometimes, we need to stuff an integer ID into a string, for example when generating HTML form <select> items.

Calling int.ToString() can result in digits outside the range [0-9] in certain cultures. For that reason, you need to specify the invariant culture in culture-spanning apps (e.g. int.ToString(CultureInfo.InvariantCulture)).

Is it worth taking care and doing that even if it is known that the application will only run in one specific western culture (e.g. German)? It seems to be the "correct" thing to do. Or is that effort not well spent?

Update: It appears that integer formatting is almost immune to culture anyway. My assumption was wrong but I'll keep the text for context.

    Tweeted twitter.com/StackProgrammer/status/730114615997239297
2 added 201 characters in body
source | link

Sometimes, we need to stuff an integer ID into a string, for example when generating HTML form <select> items.

Calling int.ToString() can result in digits outside the range [0-9] in certain cultures. For that reason, you need to specify the invariant culture in culture-spanning apps (e.g. int.ToString(CultureInfo.InvariantCulture)).

Is it worth taking care and doing that even if it is known that the application will only run in one specific western culture (e.g. German)? It seems to be the "correct" thing to do. Or is that effort not well spent?

Update: It appears that integer formatting is almost immune to culture anyway. My assumption was wrong but I'll keep the text for context.

Sometimes, we need to stuff an integer ID into a string, for example when generating HTML form <select> items.

Calling int.ToString() can result in digits outside the range [0-9] in certain cultures. For that reason, you need to specify the invariant culture in culture-spanning apps (e.g. int.ToString(CultureInfo.InvariantCulture)).

Is it worth taking care and doing that even if it is known that the application will only run in one specific western culture (e.g. German)? It seems to be the "correct" thing to do. Or is that effort not well spent?

Sometimes, we need to stuff an integer ID into a string, for example when generating HTML form <select> items.

Calling int.ToString() can result in digits outside the range [0-9] in certain cultures. For that reason, you need to specify the invariant culture in culture-spanning apps (e.g. int.ToString(CultureInfo.InvariantCulture)).

Is it worth taking care and doing that even if it is known that the application will only run in one specific western culture (e.g. German)? It seems to be the "correct" thing to do. Or is that effort not well spent?

Update: It appears that integer formatting is almost immune to culture anyway. My assumption was wrong but I'll keep the text for context.

1
source | link

Is it worth the effort to use culture invariant string formatting in single-culture applications?

Sometimes, we need to stuff an integer ID into a string, for example when generating HTML form <select> items.

Calling int.ToString() can result in digits outside the range [0-9] in certain cultures. For that reason, you need to specify the invariant culture in culture-spanning apps (e.g. int.ToString(CultureInfo.InvariantCulture)).

Is it worth taking care and doing that even if it is known that the application will only run in one specific western culture (e.g. German)? It seems to be the "correct" thing to do. Or is that effort not well spent?