c# - Text.Encoding.Default.GetBytes() / Encoding.Default.GetString() / Xamarin -
i have programmed server , client application under xamarin c# (for pc , android phone).
now have problem umlauts (äöüÄÖÜ) @ text.encoding.default.getbytes () / encoding.default.getstring ().
if server , client running on pc, umlauts converted correctly. when operated smartphone , pc question marks issued on conversion of umlauts. other data converted properly.
where problem?
private void cbuttonsend_click(object sender, eventargs e) { try { if (caktiveclient == "") toast.maketext(this, "wählen sie einen client aus!", toastlength.long).show(); else { string txt = csendetext.text; byte[] telegramm = new byte[txt.length]; telegramm = system.text.encoding.default.getbytes(txt); foreach (tcpclient c in cserver.clientlist) { if (c.client.remoteendpoint.tostring() == caktiveclient) cserver.send(c, telegramm); } csendetext.text = ""; } } catch (exception ex) { toast.maketext(this, ex.message, toastlength.short).show(); } } private void cserver_recieve(object sender, eventargs e) { // bei aufrufen aus anderenthreads this.runonuithread(() => { try { tcpip_multiserver t = sender tcpip_multiserver; cempfangsclient.text = t.nowclient.client.remoteendpoint.tostring(); cempfangstext.text = encoding.default.getstring(cserver.buffer, 0, cserver.recievedbytes); } catch (exception ex) { toast.maketext(this, ex.message, toastlength.long).show(); } }); }
to reduce size of application, xamarin doesn't include specific encodings.
read this: https://developer.xamarin.com/guides/ios/advanced_topics/localization_and_internationalization/encodings/ (on android it's same)
and this: https://developer.xamarin.com/guides/cross-platform/xamarin-forms/localization/
Comments
Post a Comment