Hi Friends,
I am pretty new to .net. I learnt basic and try to implement the same in coding.
Now, I need to replace the Extended characters supported by ISO-8859-1 model ( Latin -1) characters to my own choice characters.
I need to write a method, So that I can call anywhere. Method should replace existing string that includes latin words into choice of mine.
Sample code is attached here. Your suggestions will helpful for me.
or Correct me, Where I am going wrong in this code?
Thanks
Code written is as shown below.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace New_Req
{
public class Program
{
static void Main(string[] args)
{
StringBuilder s = "€ƒ…†‡‰ŠŒŽ•š";// a sample Latin word to check the functionality
byte[] ASCIIValues = System.Text.Encoding.Default.GetBytes(s);
foreach (byte b in ASCIIValues)
{
switch(b)
{
case 161:
{
var e = Encoding.GetEncoding("ISO-8859-1");
var s = e.GetString(new byte[] { b });
string equivalentLetter = Encoding.Default.GetString(new byte[] { (byte)letter });
//!
//s.Replace('€',);
break;
}
case 191:
{
//?
break;
}
case 192:
case 193:
case 194:
case 195:
case 196:
case 197:
case 224:
case 225:
case 226:
case 227:
case 228:
case 229:
case 230:
{
//A
break;
}
case 199:
case 231:
{
//C
break;
}
case 151:
{
//-
break;
}
case 198:
case 200:
case 201:
case 202:
case 203:
case 232:
case 233:
case 234:
case 235:
{
//E
break;
}
case 131:
{
//F
break;
}
case 204:
case 205:
case 206:
case 207:
case 236:
case 237:
case 238:
case 239:
{
//I
break;
}
case 209:
case 241:
{
//N
break;
}
case 140:
case 156:
case 210:
case 211:
case 212:
case 213:
case 214:
case 216:
case 242:
case 243:
case 244:
case 245:
case 246:
case 248:
{
//O
break;
}
case 138: case 154:
{
//S
break;
}
case 130:
case 132:
case 145:
case 146:
case 147:
case 148:
case 150:
case 166:
{
//Same character as it is
break;
}
case 128:
case 133:
case 134:
case 135:
case 136:
case 137:
case 139:
case 149:
case 152:
case 153:
case 155:
case 160:
case 162:
case 163:
case 164:
case 165:
case 167:
case 168:
case 169:
case 170:
case 171:
case 172:
case 173:
case 174:
case 175:
case 176:
case 177:
case 178:
case 179:
case 180:
case 181:
case 182:
case 183:
case 184:
case 185:
case 186:
case 187:
case 188:
case 189:
case 190:
case 208:
case 222:
case 223:
case 240:
case 247:
case 254:
{
//Give a space
break;
}
case 217:
case 218:
case 219:
case 220:
case 249:
case 250:
case 251:
case 252:
{
//U
break;
}
case 215:
{
//X
break;
}
case 159:
case 221:
case 221:
case 253:
case 255:
{
//Y
break;
}
case 142:
case 158:
{
//Z
break;
}
default :
{
//Do nothing
break;
}
}
Console.WriteLine(b);
}
Console.ReadLine();
}
}
}