encoding

How to change testNG Reporter.log() encoding to UTF-16

本小妞迷上赌 提交于 2020-02-07 09:57:15
问题 I am using testNG with selenium. I have two kind of logger, one is log4j logger and the other is testNG Reporter.log() . Now the problem is I need to log some Chinese text. But it is coming as '????' instead of Chinese text. So I changed the log4j.properties file, just added two lines: log4j.appender.file=org.apache.log4j.DailyRollingFileAppender log4j.appender.file.encoding=UTF-16 Now in my log4j logs it is coming properly but in testNG Reporter.log() it's still coming as '?????'. Log4j log:

How to change testNG Reporter.log() encoding to UTF-16

一世执手 提交于 2020-02-07 09:55:05
问题 I am using testNG with selenium. I have two kind of logger, one is log4j logger and the other is testNG Reporter.log() . Now the problem is I need to log some Chinese text. But it is coming as '????' instead of Chinese text. So I changed the log4j.properties file, just added two lines: log4j.appender.file=org.apache.log4j.DailyRollingFileAppender log4j.appender.file.encoding=UTF-16 Now in my log4j logs it is coming properly but in testNG Reporter.log() it's still coming as '?????'. Log4j log:

Is there a way to encode any number into a series of 8-bit numbers, including a terminating character?

折月煮酒 提交于 2020-02-06 09:07:52
问题 So I would like to encode numbers as small as 0 and as high as very high (32-bit, 64-bit, other 8-bit multiples...). The simple approach is to just use the computer architecture's built-in support for "word" size or whatever, so like 32-bit or 64-bit are the common cases, so integers limited to that size. But I would like to do a theoretical thing and see if there is a way to encode arbitrarily large numbers using a sequence of 8-bit numbers. But then as a caveat, I want to know when we've

Decoding/Encoding a struct with protocol type properties

谁说胖子不能爱 提交于 2020-02-06 08:08:14
问题 I am trying to save a configuration data structure with UserDefaults , thus the data structure needs to conform to the Codable protocol. This is my data structure: // Data structure which saves two objects, which conform to the Connection protocol struct Configuration { var from: Connection var to: Connection } protocol Connection: Codable { var path: String { get set } } // Two implementations of the Connection protocol struct SFTPConnection: Connection, Codable { var path: String var user:

Why does DOMDocument::saveHTML()'s behavior differ in encoding UTF-8 as entities in style & script elements?

不打扰是莪最后的温柔 提交于 2020-02-05 07:15:14
问题 Given a DOMDocument constructed with a stylesheet that contains an emoji character like so: $dom = new DOMDocument(); $dom->loadHTML( "<!DOCTYPE html><html><head><meta charset=utf-8><style>span::before{ content: \"⚡️\"; }</style></head><body><span></span></body></html>" ); I've found some strange behavior when serializing the DOM back out to HTML. If I do $dom->saveHTML( $dom->documentElement ) then I get (as desired): <html><head><meta charset="utf-8"> <style>span::before{ content: "⚡️"; }<

ActionMailer non-ASCII characters

柔情痞子 提交于 2020-02-04 11:51:24
问题 I'm trying to send text/plain emails with ActionMailer that have non-ASCII characters in them. However, an email with the contents: “This has smart quotes” Displays in emails (and the logs) as: =E2=80=9CThis has smart quotes=E2=80=9D And the Content-Transfer-Encoding of the email is quoted-printable . In the view, this text is rendered like so: <%= raw(strip_tags(@message)) %> I'm not sure where this is happening, the charset header of the email is UTF-8. This is Ruby 1.9.3-p194 and Rails 3.2

Get Clipboard String Encoding (java)

大城市里の小女人 提交于 2020-02-04 09:28:33
问题 I was wondering if theres a way to use Java to get the encoding type of a string on the clipboard. (I'd give more details but the question is fairly straight forward). Ex. I go into a unicode program, copy text, use the Java program to decipher it, and the java program spits out "UTF-16" 回答1: To access the clipboard, you can use the awt datatransfer classes. To detect the charset, you can use the CharsetDetector from ICU project. Here is the code : public static String getClipboardCharset ()

Websphere 8.5.5 UTF-8 encoding issue

╄→尐↘猪︶ㄣ 提交于 2020-02-03 10:36:29
问题 I have a problem with my application on Websphere 8.5.5 . It's a spring rest application that is used to send email. In my service I receive the mail details and I use spring to forward it to the receivers. It works fine but when I try to send messages with non ascii character the message arrives with the special characters replaced by a question mark. The UTF-8 encoding doesn't work. In my pc the application runs on Liberty Profile server and initially it doesn't work either. I googled the

Java: Base64 Encode a String using a key

隐身守侯 提交于 2020-02-02 23:43:07
问题 Hi I have data and a key (both strings). The data needs to be encode using the key using Base64. Can some one give me a sample code. 回答1: Base64 is not for 'encoding with a key'. It is simply a encoding scheme: you can use Base64 to encrypt and decrypt strings without any extra's. It's just for very (very) basic security usages. 回答2: you can xor the data with your key and then base64 encode it. var key = "mykey"; var mydata = "some long text here"; var output = ''; for (var i = 0, len =

Different behaviour and output when piping through CMD and PowerShell

不羁的心 提交于 2020-02-02 13:16:43
问题 I am trying to pipe the content of a file to a simple ASCII symmetrical encryption program i made. It's a simple program that reads input from STDIN and adds or subtracts a certain value (224) to each byte of the input. For example: if the first byte is 4 and we want to encrypt, then it becomes 228. If it exceeds 255, the program just performs some modulo. This is the output I get with cmd (test.txt contains "this is a test"): type .\test.txt | .\Crypt.exe --encrypt | .\Crypt.exe --decrypt