Special chars displaying properly on every computer [closed] - c++

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Can this code assure that Polish special chars will be properly displayed on every computer?
locale locpol("Polish_Poland");
locale::global(locpol);
cout.imbue(locpol);
cin.imbue(locpol);
On mine it works, cannot say about any other PC as I'm limited to only one.
Second thought: how can I preserve special chars during i/o operations and comparison. I've been told Windows has different char-codes for receiving and displaying chars. Is this true? How can I properly compare strings with special characters?
Do I need to imbue locale on... let's say - every ofstream/ifstream object I create? Like this:
textfile.imbue(locpol);
?

No.
The names of the locales are not standardized, so there are no guarantees across operating systems.

Related

Is there any optimal way to implement N byte integer and it's arithmetic operations in c++? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 months ago.
Improve this question
I'm trying to think of some interesting, reusable way to implement big integers using passed amount of bytes or resizing themselves when needed. I have no idea how to make it optimal in any way tho. Are there any tricks I could use, or do I have to simply work on those numbers bit by bit while adding/multiplying/dividing?
edit: if it is important, I need it to safe text as number in base 10 so I can play with some ideas for encrypting it
Use The GNU Multiple Precision Arithmetic Library. If you try to reinvent the wheel you will end up with a square.

Should I make two versions of one program, each with different language, or add an option to change language? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I have a program that I'm currently writing in English. In future, I would like to make the program multilingual, therefore I'm wondering what's the best option to do so. I thought about this two option for now:
Enable users to change language in settings;
Select the appropriate language while downloading;
With each option comes a problem:
A ton of code dedicated to displaying one message in different languages;
I will have to make many versions just to change the language of the displayed text;
Now my question is, which one of these options is more memory efficient and user friendly? Maybe neither of them are? Do you have any other option that is better than given two?
It is common to have an array or other structure, called something like strings, containing all the display strings your program will need. Instead of hardcoding messages into your program, you reference the array. To change language, you just alter the array.

Count char occurs in string with length 10^200 [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a string on Linux standard terminal input. Its maximal length is 10^200 (as said in program specification). I have to count, how many "3" characters are inside it (occur in this string). I couldn't do that by for loop, because there is no so big variable type, which can be used as iterator. Is there any way to analyze so big strings?
Is there any way to analyze so big strings?
Not in this universe there is not. Such an entity cannot exist in this universe1 and that which does not exist, cannot be analyzed.
1 Current estimates of this universe's total number of particles particles are in the region of 1080.
As from your comment
The data source is standard terminal input.
Then you'll need a lot of monkeys to type this in.
Though you don't need to read in what's typed at once into a big string, but you can simply analyze char by char as typed. The std::istream::get(char_type& ch) method is suitable for doing so.

Is it efficient to have 85620 object of a class? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am writing a program which reads from a file and processes the data in the file. Each line in the file is an entity. There are 85620 lines in the file. Is it efficient to define a class of the entity and have 85620 instances of that class?
Depends a bit on the class. But in general, 80k objects is a non-concern.
Yes, especially if you're storing them in a memory-efficient container like std::vector (hint: reserve some space up front if you know you always need at least a thousand or so).
It depends on a lot of factor, and the target software/hardware requirements.
On modern computer with 8GB+ memory, 80k object with even 1K each would not be a big deal, however it may be an issue on mobile phone or embedded systems.
Also note that if you are doing single pass processing and do not need the data afterward, there is no reason to store them.

Regexp for firstname and lastname [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I would like to find a regular expresson for validating user input for FirstName and LastName. Is there som kind of standard for this? I would like to avoid strange signs, yet allow international signs like åäö, etc.
I am using .NET
Any recommendations?
It seems that there is no single simple aswers. Closing this topic.
This is not so easy to do.
One way to do it is like this:
[a-zA-Zåäö] etc.
Just add all the special characters needed to the list of allowed characters, but it's not how you should do it.
Instead, check this question on why this is a really difficult problem to solve:
What are all of the allowable characters for people's names?