encoding

Android UTF-8 encoding not working?

亡梦爱人 提交于 2020-01-16 18:53:28
问题 I am working with a CSV file right now. In my program i am using an OutputStreamWriter to write data the csv file. OutputStreamWriter myOutWriter = new OutputStreamWriter(fOut, Charset.forName("UTF-8").newEncoder()); I tried printing out the encoding style of this writer and get the following: Log.i(TAG, "BODY ENCODING: " + myOutWriter.getEncoding()); Logcat: BODY ENCODING: UTF-8 But when i try to open the csv file on my desktop it says that the file is in windows-1252 so i cant read æøå

preg_match is matching two characters when it should only match one

我的未来我决定 提交于 2020-01-16 12:45:35
问题 I'm trying to extract the special characters (out of a predefined pattern) from a string, but when that string begins with an inverted question mark, "matches" returns first two characters, including a not special one. Eg.: $string = '¿hola?'; $string2 = mb_convert_encoding($string, 'UTF-8'); $regex = mb_convert_encoding('/[a-zäáàëéèíìöóòúùñç]/', 'UTF-8'); if(preg_match($regex, $string2, $matches, PREG_OFFSET_CAPTURE)) { //--> We pick the special characters into "$resultado1": $resultado1 =

preg_match is matching two characters when it should only match one

非 Y 不嫁゛ 提交于 2020-01-16 12:43:24
问题 I'm trying to extract the special characters (out of a predefined pattern) from a string, but when that string begins with an inverted question mark, "matches" returns first two characters, including a not special one. Eg.: $string = '¿hola?'; $string2 = mb_convert_encoding($string, 'UTF-8'); $regex = mb_convert_encoding('/[a-zäáàëéèíìöóòúùñç]/', 'UTF-8'); if(preg_match($regex, $string2, $matches, PREG_OFFSET_CAPTURE)) { //--> We pick the special characters into "$resultado1": $resultado1 =

why do i have to use mb_convert_encoding($name,'ISO-8859-15','utf-8') to get accented chars to display?

邮差的信 提交于 2020-01-16 11:20:11
问题 the data im working with here is off of a page that uses utf8 encoding i've set my database and fields to use utf8_general_ci now for whatever reason, i have to use the following code on the variable in order to have it display accented characters correctly in the database: mb_convert_encoding($name,'ISO-8859-15','utf-8'); this makes no sense to me. why do i have to convert it to ISO-8859-15 when phpmyadmin is in utf8, the data is in utf8, and the database and table fields are in utf8? 回答1:

Which parts of a URL need to be encoded?

旧时模样 提交于 2020-01-16 06:09:26
问题 With POST is easy and automatic: just use application/x-www-form-urlencoded or multipart/form-data or whatever. Instead, what parts should be encoded in a GET request? The whole query string? Just the parameter values but not the names ? And the fragment ? Maybe also the path ? But am pretty sure that I shouldn't encode the host or the scheme (since there are encoding and specs for international domains, like in japanese etc.). Hence the question is more about the URI 😉 Strangely I didn't

Jasperreport CSV UTF-8 without BOM instead of UTF-8

时光毁灭记忆、已成空白 提交于 2020-01-16 04:45:10
问题 I try to export a CSV file with JasperReport, the problem is when I want to print currency like '€'. When I search for solution, I realized that it's about file encoding! I write this code! //JasperPrint is already filled HttpServletResponse httpServletResponse = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse(); httpServletResponse.setContentType("application/csv; charset="+Charset.forName("utf-8").displayName()); httpServletResponse

How can I replace text in PDF with iText without encoding issue? (Android)

て烟熏妆下的殇ゞ 提交于 2020-01-16 04:37:05
问题 I need some help. I want to replace a text with an another in a PDF file (I'm using iText library), but when I'm trying to do it with accent letters, it has encoding problems. public static void manipulatePdf(String src, String dest) throws IOException, DocumentException { PdfReader reader = new PdfReader(src); PdfDictionary dict = reader.getPageN(1); PdfObject object = dict.getDirectObject(PdfName.CONTENTS); if (object instanceof PRStream) { PRStream stream = (PRStream) object; byte[] data =

Javascript AES encryption doesn't match iOS AES encryption

烈酒焚心 提交于 2020-01-16 04:24:32
问题 I am encrypting an NSString in iOS like this which encodes and decodes fine: NSString *stringtoEncrypt = @"This string is to be encrypted"; NSString *key = @"12345678901234567890123456789012"; // Encode NSData *plain = [stringtoEncrypt dataUsingEncoding:NSUTF8StringEncoding]; NSData *cipher = [plain AES256EncryptWithKey:key]; NSString *cipherBase64 = [cipher base64EncodedString]; NSLog(@"ciphered base64: %@", cipherBase64); // Decode NSData *decipheredData = [cipherBase64 base64DecodedData];

FFmpegFrameGrabber crashes 100% of time attempting to compress video on Android

感情迁移 提交于 2020-01-15 12:17:07
问题 I am attempting to use javacv/ffmpeg to compress video on an Android device prior to upload. I am using this code: FrameGrabber grabber = new FFmpegFrameGrabber(inputFile.getAbsolutePath()); grabber.start(); FFmpegFrameRecorder recorder = new FFmpegFrameRecorder(outputFile.getAbsolutePath(), grabber.getImageWidth(), grabber.getImageHeight(), grabber.getAudioChannels()); recorder.setVideoCodec(com.googlecode.javacv.cpp.avcodec.AV_CODEC_ID_MPEG4); recorder.setAudioCodec(com.googlecode.javacv

Android - Characters such as å,ä,ö do not render correctly in WebView

青春壹個敷衍的年華 提交于 2020-01-15 12:02:53
问题 I am using the following code to render my webview in android - webview.loadDataWithBaseURL(null, "Subject: "+ getSubject() +" Content: "+ getContent() , "text/html" , "UTF-8", ""); The subject and content that I receive from the server are UTF encoded and show wrongly as Ã¥,ä,ö in the log and on screen. However in iOS webview they show up correctly as å,ä,ö. How do I get them to show as å,ä,ö in android as well? 回答1: make sure the content you recieve, in tag <head> use like this: <meta