在这篇文章中,我们将带领您了解SQL外壳client_encoding无法正确显示“UTF8”或“WIN1252”的全貌,同时,我们还将为您介绍有关angular–MatDialog无法正确显示、c#
在这篇文章中,我们将带领您了解SQL外壳 client_encoding无法正确显示“ UTF8”或“ WIN1252”的全貌,同时,我们还将为您介绍有关angular – MatDialog无法正确显示、c# – Convert.ToBase64String / Convert.FromBase64String和Encoding.UTF8.GetBytes / Encoding.UTF8.GetString之间的区别、c# – Encoding.UTF8.GetString和Encoding.UTF8.GetBytes彼此不相反的原因是什么?、C# 中 UTF8Encoding.UTF8.GetBytes(key),,对应PHP中的哪个方法? 怎么写?的知识,以帮助您更好地理解这个主题。
本文目录一览:- SQL外壳 client_encoding无法正确显示“ UTF8”或“ WIN1252”
- angular – MatDialog无法正确显示
- c# – Convert.ToBase64String / Convert.FromBase64String和Encoding.UTF8.GetBytes / Encoding.UTF8.GetString之间的区别
- c# – Encoding.UTF8.GetString和Encoding.UTF8.GetBytes彼此不相反的原因是什么?
- C# 中 UTF8Encoding.UTF8.GetBytes(key),,对应PHP中的哪个方法? 怎么写?
SQL外壳 client_encoding无法正确显示“ UTF8”或“ WIN1252”
尝试设置lc_messages = C
,以便以可以WIN1252
编码的语言显示错误消息。
您最好在postgresql.conf
中更改设置并重新加载。此设置还将影响日志文件的语言,如果您要在网络上搜索错误消息,则英语是最佳选择。
angular – MatDialog无法正确显示
import {Component,Inject,OnInit} from '@angular/core'; import {Router} from '@angular/router'; import {AuthenticationService} from '../../../service/authentication.service'; import {MAT_DIALOG_DATA,MatDialog,MatDialogRef} from '@angular/material'; @Component({ selector: 'app-home',templateUrl: './home.component.html',styleUrls: ['./home.component.css'] }) export class HomeComponent { constructor(private router: Router,public dialog: MatDialog) { } openDialog(): void { const dialogRef = this.dialog.open(CreateGroupDialogComponent); } } @Component({ selector: 'app-create-group-dialog',template: ` <span>Hello World!</span> ` }) export class CreateGroupDialogComponent { constructor(public dialogRef: MatDialogRef<CreateGroupDialogComponent>) { } }
但是,即使按下相应按钮时对话框出现,我得到的是:
不显示HTML模板,并且模式的尺寸错误.
我不知道问题是什么.为什么模态没有正确绘制?
这是打开模态时生成的HTML代码.可以看出它是空的.
解决方法
import { browserModule } from '@angular/platform-browser'; import { browserAnimationsModule } from '@angular/platform-browser/animations'; import { NgModule } from '@angular/core'; import { MatDialogModule,MatButtonModule } from '@angular/material'; import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; import { LoginComponent } from './login/login.component'; import { HomeComponent,DialogoverviewExampleDialogComponent } from './home/home.component'; @NgModule({ declarations: [ AppComponent,LoginComponent,HomeComponent,DialogoverviewExampleDialogComponent ],imports: [ browserModule,browserAnimationsModule,AppRoutingModule,MatDialogModule,MatButtonModule ],providers: [],bootstrap: [AppComponent],entryComponents: [ DialogoverviewExampleDialogComponent ] }) export class AppModule { }
重复Angular2 material dialog has issues – Did you add it to @NgModule.entryComponents?
c# – Convert.ToBase64String / Convert.FromBase64String和Encoding.UTF8.GetBytes / Encoding.UTF8.GetString之间的区别
private byte[] key = Encoding.ASCII.GetBytes("abcdefgh"); private byte[] IV = Encoding.ASCII.GetBytes("hgfedcba"); private byte[] encrypted; public Form1() { InitializeComponent(); } private void btnEncrypt_Click(object sender,EventArgs e) { this.textBox2.Text = this.Encrypt(this.textBox1.Text); } private void btnDecrypt_Click(object sender,EventArgs e) { this.textBox3.Text = this.Decrypt(this.textBox2.Text); } private string Encrypt(string plainText) { try { using (DESCryptoServiceProvider crypto = new DESCryptoServiceProvider()) { crypto.Key = this.key; crypto.IV = this.IV; ICryptoTransform transform = crypto.CreateEncryptor(crypto.Key,crypto.IV); using (MemoryStream stream = new MemoryStream()) { using (CryptoStream cryptoStream = new CryptoStream(stream,transform,CryptoStreamMode.Write)) { using (StreamWriter writer = new StreamWriter(cryptoStream)) { writer.Write(plainText); } encrypted = stream.ToArray(); } } } return Convert.ToBase64String(encrypted); } catch (Exception) { throw; } } private string Decrypt(string cipherText) { try { string plainText = string.Empty; using (DESCryptoServiceProvider crypto = new DESCryptoServiceProvider()) { crypto.Key = this.key; crypto.IV = this.IV; ICryptoTransform transform = crypto.CreateDecryptor(crypto.Key,crypto.IV); using (MemoryStream stream = new MemoryStream(Convert.FromBase64String(cipherText))) { using (CryptoStream cryptoStream = new CryptoStream(stream,CryptoStreamMode.Read)) { using (StreamReader reader = new StreamReader(cryptoStream)) { plainText = reader.ReadToEnd(); } } } } return plainText; } catch (Exception) { throw; } }
一切都按预期工作.但如果我更换
return Convert.ToBase64String(encrypted);
和
using (MemoryStream stream = new MemoryStream(Convert.FromBase64String(cipherText)))
至
return Encoding.UTF8.GetString(encrypted);
和
using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(cipherText)))
我在CryptoStream System.NotSupportedException中有错误.在诊断代码之后,我发现Encoding.UTF8.GetBytes(cipherText)具有比加密更多的字节
那么使用Convert.From / ToBase64String和Encoding.UTF8.GetBytes / GetString有什么区别呢?
解决方法
Base64是二进制到文本编码.它将字节编码为文本.
在这种情况下你需要后者.
Encoding.UTF8.GetString解码一个UTF-8编码的字节数组,如果存在无效的字节序列(这很有可能是像密文一样给它随机字节),那么它是有损的.
c# – Encoding.UTF8.GetString和Encoding.UTF8.GetBytes彼此不相反的原因是什么?
在以下示例中,myOriginalBytes和asBytes不相等,即使它们的长度不同.谁能解释我错过了什么?
byte[] myOriginalBytes = GetRandomByteArray(); var asstring = Encoding.UTF8.GetString(myOriginalBytes); var asBytes = Encoding.UTF8.GetBytes(asstring);
解决方法
让我们来看一个具体而简单的例子:单个字节0xff.这不是任何文本的有效UTF-8编码.所以如果你有:
byte[] bytes = { 0xff }; string text = Encoding.UTF8.GetString(bytes);
…你最终将文本作为单个字符,U+FFFD,“Unicode替换字符”,用于表示解码二进制数据时出错.对于任何无效序列,您最终会得到替换字符 – 例如,如果以0x80开头,则会获得相同的文本.显然,如果多个二进制输入被解码为相同的文本输出,则它不可能是完全可逆的变换.
如果您有任意二进制数据,则不应使用Encoding从中获取文本 – 您应该使用Convert.ToBase64String或者hex.编码用于自然文本的数据.
如果你走向相反的方向,像这样:
string text = GetRandomText(); byte[] bytes = Encoding.UTF8.GetBytes(text); string text2 = Encoding.UTF8.GetString(bytes);
…我希望text2等于文本,除了你有无效文本的奇怪情况,例如与“一半”代理对.
C# 中 UTF8Encoding.UTF8.GetBytes(key),,对应PHP中的哪个方法? 怎么写?
c# 中 utf8encoding.utf8.getbytes(key),,对应php中的哪个方法?
怎么写?
回复讨论(解决方案)
我们今天的关于SQL外壳 client_encoding无法正确显示“ UTF8”或“ WIN1252”的分享就到这里,谢谢您的阅读,如果想了解更多关于angular – MatDialog无法正确显示、c# – Convert.ToBase64String / Convert.FromBase64String和Encoding.UTF8.GetBytes / Encoding.UTF8.GetString之间的区别、c# – Encoding.UTF8.GetString和Encoding.UTF8.GetBytes彼此不相反的原因是什么?、C# 中 UTF8Encoding.UTF8.GetBytes(key),,对应PHP中的哪个方法? 怎么写?的相关信息,可以在本站进行搜索。
本文标签: