encoding

Android-分辨率以及dip(dp)、dpi、ppi、px、sp、pt说明

你说的曾经没有我的故事 提交于 2020-04-12 17:43:43
dip(dp): device independent pixels(设备独立像素) dip,就是把屏幕的高分成480分,宽分成320分。比如你做一条160dip的横线,无论你在320还480的模拟器上,都是一半屏的长度。 dpi:dot per inch dpi=(√(横向分辨率^2+纵向分辨率^2))/屏幕尺寸) ppi:pixels per inch(跟dpi一样) 计算了一下小米手机屏幕的PPI,4.0英寸、分辨率854X480,PPI(DPI)   =√(854^2+480^2)/4=244.912……≈245. px:pixel sp: scaled pixels(放大像素), 主要用于字体显示。 pt: point,是一个标准的长度单位, 1pt=1/72英寸,用于印刷业。 平常所说的hdpi等划分方法(按DPI来划分): 关于分辨率适配: 一、细说 layout_weight 目前最为推荐的 Android 多屏幕自适应解决方案。 该属性的作用是决定控件在其父布局中的显示权重,一般用于线性布局中。 其值越小,则对应的layout_width或layout_height的优先级就越高,一般横向布局中,决定的是 layout_width 的优先级;纵向布局中,决定的是 layout_height 的优先级。 传统的 layout_weight 使用方法是将当前控件的

Java - Count exactly 60 characters from a string with a mixture of UTF-8 and non UTF-8 characters

落花浮王杯 提交于 2020-04-11 06:01:26
问题 I have a string which i want to save in a database that only supports UTF8 characters. If the string size is > 60 characters i want to truncate it and only store the first 60 characters. The Oracle database in use only supports UTF-8 characters. Using String.substring(0,59) in Java returns 60 characters but when i save it in the database it gets rejected as the database claims that the string is > 60 characters. Is there a way to find out if a particular string contains non UTF8 characters.

How to use operator L on array? (C++, Visual Studio 2019)

拜拜、爱过 提交于 2020-04-10 06:29:19
问题 Part 2 on encoding characters in C++ (by User123). <- Go to the previous post. I was yesterday making some code, and Paul Sanders in this question told me useful solution: He told me not to use std::cout << "something"; but to use std::wcout << L"something"; . But I have another problem. Now I want to do something like this (some special characters, but in array): #include <iostream> using namespace std; string myArray[2] = { "łŁšđřžőšě", "×÷¤ßł§ř~ú" }; int main() { cout << myArray[0] << endl

dump json into yaml

你说的曾经没有我的故事 提交于 2020-04-07 14:53:06
问题 I got a .json file (named it meta.json ) like this: { "main": { "title": "今日は雨が降って", "description": "今日は雨が降って" } } I would like to convert it to a .yaml file (named it meta.yaml ) like : title: "今日は雨が降って" description: "今日は雨が降って" What I have done was : import simplejson as json import pyyaml f = open('meta.json', 'r') jsonData = json.load(f) f.close() ff = open('meta.yaml', 'w+') yamlData = {'title':'', 'description':''} yamlData['title'] = jsonData['main']['title'] yamlData['description'] =

Perl + Curses: Expecting a UTF-8 encoded multibyte character from getchar(), but not getting any

这一生的挚爱 提交于 2020-04-07 05:13:37
问题 I am trying out Bryan Henderson's Perl interface to the ncurses library: Curses For a simple exercise, I try to obtain single characters typed on-screen. This is directly based off the NCURSES Programming HOWTO, with adaptations. When I call the Perl library's getchar() , I expect to receive a character, possibly multibyte (It's a bit more complicated as explained in this part of the library manpage because one has to handle the special cases of function keys and no input, but that's just the

Perl + Curses: Expecting a UTF-8 encoded multibyte character from getchar(), but not getting any

笑着哭i 提交于 2020-04-07 05:13:31
问题 I am trying out Bryan Henderson's Perl interface to the ncurses library: Curses For a simple exercise, I try to obtain single characters typed on-screen. This is directly based off the NCURSES Programming HOWTO, with adaptations. When I call the Perl library's getchar() , I expect to receive a character, possibly multibyte (It's a bit more complicated as explained in this part of the library manpage because one has to handle the special cases of function keys and no input, but that's just the

Encoding.RegisterProvider(CodePagesEncodingProvider.Instance) does not add extra encoding providers

北城余情 提交于 2020-03-19 05:18:17
问题 I am developing a netcoreapp2.0 console application and I need access to the whole encoding package from .NET. I have already added the System.Text.Encoding.CodePages Version=4.4.0 Nuget package from this page to my project and cleaned/restored the project several time. However I can't get the extra encoding I need. The following code: Console.WriteLine(Encoding.GetEncodings().Length); Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); Console.WriteLine(Encoding.GetEncodings()

Original file bytes from StreamReader, magic number detection

限于喜欢 提交于 2020-03-18 12:15:37
问题 I'm trying to differentiate between "text files" and "binary" files, as I would effectively like to ignore files with "unreadable" contents. I have a file that I believe is a GZIP archive. I'm tring to ignore this kind of file by detecting the magic numbers / file signature. If I open the file with the Hex editor plugin in Notepad++ I can see the first three hex codes are 1f 8b 08 . However if I read the file using a StreamReader , I'm not sure how to get to the original bytes.. using (var

JavaScript blob encoding as UTF-8 instead of ANSI

橙三吉。 提交于 2020-03-18 06:31:50
问题 I use a JavaScript blob to create an FDF file which opens & fills in a locally stored PDF. However, the file path to the locally stored PDF contains an accented character (and I am unable to edit the folder name). This code works when the folder path doesn’t contain an accent and if I open the fdf in Notepad, the default encoding is ANSI. But when the folder path contains an accent, the FDF opens to a message stating the PDF cannot be found. Furthermore, the default encoding in Notepad has

Encrypting string gives different results

≡放荡痞女 提交于 2020-03-06 11:06:15
问题 I've been given the task to make two older systems work together. The first is written in ASP Classic and the second in C#. The ASP-C system have generated an encrypted string and stored in the database. Now I need the C# to do the same; providing the str and key should give the same result as the ASP-C. The str: 1234567890 The key: 12$1$doFmp8gD$7Es.78EumklLvtraylRQy034 The ASP-C encryption function: Function EncryptString(str, key) newStr = "" strLen = Len(str) keyLen = Len(key) keyPos = 1