utf-8

How do I write out a text file in C# with a code page other than UTF-8?

感情迁移 提交于 2020-01-18 21:06:56
问题 I want to write out a text file. Instead of the default UTF-8, I want to write it encoded as ISO-8859-1 which is code page 28591. I have no idea how to do this... I'm writing out my file with the following very simple code: using (StreamWriter sw = File.CreateText(myfilename)) { sw.WriteLine("my text..."); sw.Close(); } 回答1: using System.IO; using System.Text; using (StreamWriter sw = new StreamWriter(File.Open(myfilename, FileMode.Create), Encoding.WhateverYouWant)) { sw.WriteLine("my text..

How do I write out a text file in C# with a code page other than UTF-8?

六眼飞鱼酱① 提交于 2020-01-18 21:06:25
问题 I want to write out a text file. Instead of the default UTF-8, I want to write it encoded as ISO-8859-1 which is code page 28591. I have no idea how to do this... I'm writing out my file with the following very simple code: using (StreamWriter sw = File.CreateText(myfilename)) { sw.WriteLine("my text..."); sw.Close(); } 回答1: using System.IO; using System.Text; using (StreamWriter sw = new StreamWriter(File.Open(myfilename, FileMode.Create), Encoding.WhateverYouWant)) { sw.WriteLine("my text..

How to change utf-8mb4 to UTF-8 in groovy?

ε祈祈猫儿з 提交于 2020-01-17 12:26:04
问题 Currently, I have a problem with receiving string input from user mobile. The string was inputed and contained utf8mb4 characters (smiley, emoji, etc). This caused error in my backend (mysql) since it only accepts utf-8 input. Now, how can I just replace all utf-8mb4 input to utf-8? def utf8mb4string = '👳👳👳👳👳👳👳'; // parse the utf8mb4string to utf8 // logic here //possible utf8 result maybe: '�������' I have also found similar question here How would I convert UTF-8mb4 to UTF-8? but no clear

Using Chinese fonts in TCPDF and FPDI. Encoding problems

僤鯓⒐⒋嵵緔 提交于 2020-01-17 11:15:35
问题 I am writing a script that generates Chinese character worksheets (so students can generate and practice writing) The script is passed a 15 character string from a form in index.php. The string is then exploded into an array of 15 elements (each a Chinese character). The problem arises when I want to use the Write() function to populate the file with these characters, I've used the input to pick appropiate images without any problems but now it's the encoding of the fonts that gives me a hard

URL decode ä -> ã1⁄4

好久不见. 提交于 2020-01-17 05:51:20
问题 I have the problem that the decoding from a URL causes some major problems. The request URL contains %C3%BC as the letter 'ü'. The decoding server side should now decode it as an ü, but it does this: ü decoding is done like this: decoded = URLDecoder.decode(value, "UTF-8"); while value contains '%C3%BC' and decoded should now conatain 'ü', but that's where the problem is. What's going wrong here? I use this method in more than one application and it works fine in all other cases... 回答1: I

French characters not displaying correctly in PHP mail

隐身守侯 提交于 2020-01-17 05:45:11
问题 I have a basic PHP mail form, but whatever I do, I cannot seem to get the characters to display correctly once sent, if the language is written with French accents. The example sentence I am using is: Bonjour, ceci est un message de test envoyé avec PHP pour analyser si oui ou non la mise en forme est correcte ou fausse. Les personnages ne devraient être rendus de manière appropriée comme prévu dans le lexique français. But it comes out as: Bonjour, ceci est un message de test envoyé avec

Problem with greek url characters in IE

▼魔方 西西 提交于 2020-01-17 03:23:12
问题 I'm using the following script in my website in order to create pagination "next-previous" functionality. It's a actually a Dreamweaver's code. The script uses the url to get some values and then it re-creates it. The result url in IE7 and IE8 contains non-readable characters and at the end the page does not work properly. $queryString_met = ""; if (!empty($_SERVER['QUERY_STRING'])) { $params = explode("&", $_SERVER['QUERY_STRING']); $newParams = array(); foreach ($params as $param) { if

broken UTF-8 String ruby

半腔热情 提交于 2020-01-17 03:22:06
问题 While reading a file I get broken UTF-8 String error whenever I have the following in my file través if I change it to normal e then it works. Whats the way to fix this? error only happens if I do line.lstrp or any other function. Just printing the lines is ok. problem even happens when I try to match the string with regex. 回答1: Obviously your file is not UTF-8 encoded. So, you should either take care of that (save your file using UTF-8), or tell Ruby that your strings aren't going to be UTF

IMAP message gets UnicodeDecodeError 'utf-8' codec can't decode

一曲冷凌霜 提交于 2020-01-16 19:34:31
问题 After 5 hours of trying, time to get some help. Sifted through all the stackoverflow questions related to this but couldn't find the answer. The code is a gmail parser - works for most emails but some emails cause the UnicodeDecodeError. The problem is "raw_email.decode('utf-8')" but changing it (see comments) causes a different problem down below. # Source: https://stackoverflow.com/questions/7314942/python-imaplib-to-get-gmail-inbox-subjects-titles-and-sender-name import datetime import

IMAP message gets UnicodeDecodeError 'utf-8' codec can't decode

不打扰是莪最后的温柔 提交于 2020-01-16 19:34:07
问题 After 5 hours of trying, time to get some help. Sifted through all the stackoverflow questions related to this but couldn't find the answer. The code is a gmail parser - works for most emails but some emails cause the UnicodeDecodeError. The problem is "raw_email.decode('utf-8')" but changing it (see comments) causes a different problem down below. # Source: https://stackoverflow.com/questions/7314942/python-imaplib-to-get-gmail-inbox-subjects-titles-and-sender-name import datetime import