2019-02-02 14:58:52

Hi!
I want to create a little aplication in CSharp. This function, when encounters certain characters from unicode charset should insert another character from the unicode set in place of it.
The think I wanted to do is to create a function which will accept an array as it's parameter. Then it would iterate through the whole text and replace the characters.
But how should I handle this replacing?

If you want to contact me, do not use the forum PM. I respond once a year or two, when I need to write a PM myself. I apologize for the inconvenience.
Telegram: Nuno69a
E-Mail: nuno69a (at) gmail (dot) com

2019-02-02 16:17:58

I don't want to sound too cynical here, but what about looping over the text (or array, I suppose the text is stored within the array you insert into the method via the previously mentioned parameter), and replace by index whenever some if condition emits true?
thinks like

arr[0] = 'i';

or

arr[i] = 'u';

and stuff work wonders here smile.
If thats not what you were asking, i'd recommend to specify your question more clearly, 'cause I seriously don't get what you want right now.
Best Regards.
Hijacker

2019-02-02 16:44:15

Yeah if it is just one char it's really just looping over the array and replacing elements. If you want to use a pattern this is slightly more complicated.

Roel
golfing in the kitchen

2019-02-02 16:57:54

OK, so maybe I'll explain my idea more clearly.
As you may or may not know, cyryllic alphabet is precursored by something called glagollitic.. This writing method has been used to write old slavonic text, however glagollitic can also be resembled using the today cyryllic alphabet. So I wanted to write the text converter, but... there are about 90 characters, so I really need to write 90 if statements or case blocks?

If you want to contact me, do not use the forum PM. I respond once a year or two, when I need to write a PM myself. I apologize for the inconvenience.
Telegram: Nuno69a
E-Mail: nuno69a (at) gmail (dot) com

2019-02-02 19:31:23

No, create arrays with size 90 and loop over them

Roel
golfing in the kitchen

2019-02-02 19:38:08

you can use multiple approaches here. either use an array (as suggested above), or you can use a dictionary to map those characters and do as you like. There are always multiple aproaches to a given problem, they usually only differ in algorithm speed and code elegance.
Best Regards.
Hijacker

2019-02-02 23:56:56

O yeah also a possibility if your language supports them. The reason I suggested arrays was because I've got no knowledge of C# and every language has arrays in one form or another. Dictionaries do not exist in C.

Roel
golfing in the kitchen

2019-02-03 01:47:44

OK, I already solved my problem, thanks to your help.
Thank you guys!

If you want to contact me, do not use the forum PM. I respond once a year or two, when I need to write a PM myself. I apologize for the inconvenience.
Telegram: Nuno69a
E-Mail: nuno69a (at) gmail (dot) com