Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Encoding from 1252 to Unicode
#1
Hi guys,

i have a file with german umlauts. So i need to convert it from 1252 to unicode.

In QM2 i did it this way:
 
Code:
Copy      Help
_s.ConvertEncoding(1252 _unicode)

In Libreautomate i don't get the path. I saw in C# the way around like this:
 
Code:
Copy      Help
Encoding wind1252 = Encoding.GetEncoding(1252);
Encoding utf8 = Encoding.UTF8;  
byte[] wind1252Bytes = wind1252.GetBytes(_s);
byte[] utf8Bytes = Encoding.Convert(wind1252, utf8, wind1252Bytes);
string utf8String = Encoding.UTF8.GetString(utf8Bytes);
But it asks me for an Encoding.Provider and customization. Hmmm... Sorry, i am a very bloody beginner in C# and Libreautomate.
Has anybody a hint for me how i get the string from 1252 to unicode in Libreautomate?

Many thanks
Achim
#2
Code:
Copy      Help
// script ""
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
var text = File.ReadAllText(@"C:\Test\Encoded-1252.txt", Encoding.GetEncoding(1252));
print.it(text);
#3
That did it!

Thnx Gintaras!


Forum Jump:


Users browsing this thread: 1 Guest(s)