文檔半島外圍網上直營>>telerik中文文檔>>編碼和糾錯
                編碼和糾錯
該Kendo UI for Angular 二維碼支持不同的編碼和糾錯級別。
編碼值
默認情況下,QR碼值使用“ISO_8859_1”編碼,它支持ISO/IEC 8859-1字符集中的所有字符。要啟用對所有Unicode字符的支持,請將編碼設置為"UTF_8"。
提示:UTF-8編碼不包括在規范中,也不是所有閱讀器都支持。
下面的示例展示了如何設置編碼:
查看源代碼:
app.component.ts:
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
template: `
<div class="k-card k-text-center">
<div class="k-card-header">
<div class="k-card-title">
QR Code with Unicode characters
</div>
</div>
<div class="k-card-body">
<kendo-qrcode value="Unicode за всички ??"
encoding="UTF_8" size="150px">
</kendo-qrcode>
</div>
</div>
`
})
export class AppComponent {
}
app.module.ts:
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser';
import { BarcodesModule } from '@progress/kendo-angular-barcodes';
import { ButtonsModule } from '@progress/kendo-angular-buttons';
import { AppComponent } from './app.component';
@NgModule({
imports: [ BrowserModule, BarcodesModule, ButtonsModule, FormsModule ],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
main.ts:
import './polyfills';
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app.module';
enableProdMode();
const platform = platformBrowserDynamic();
platform.bootstrapModule(AppModule);
糾錯級別
二維碼提供錯誤糾正和恢復,允許部分損壞或覆蓋的QR碼保持可讀。每一個連續的糾錯級別都提高了讀者恢復原始信息的機會:
- “L”-7%的數據可以恢復。
- “M”-15%的數據可以恢復。
- “Q” -25%的數據可以恢復。
- “H”-30%的數據可以恢復。
如果您希望覆蓋部分代碼,例如,在使用覆蓋時,請使用更高的錯誤糾正級別,二維碼的大小可能需要增加來容納額外的信息。
要設置錯誤糾正級別,使用errorCorrection屬性:
app.component.ts:
import { Component } from '@angular/core';
import { QRCodeErrorCorrection } from '@progress/kendo-angular-barcodes';
@Component({
selector: 'my-app',
template: `
<div class="k-card-deck">
<div class="k-card k-text-center"
*ngFor="let level of levels">
<div class="k-card-header">
<div class="k-card-title">
Level "{{ level }}"
</div>
</div>
<div class="k-card-body">
<kendo-qrcode [value]="value" size="120px"
[errorCorrection]="level">
</kendo-qrcode>
</div>
</div>
</div>
`
})
export class AppComponent {
public value = '//en.wikipedia.org/wiki/QR_code#Error_correction';
public levels: QRCodeErrorCorrection[] = [ 'L', 'M', 'Q', 'H' ];
}
app.module.ts:
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser';
import { BarcodesModule } from '@progress/kendo-angular-barcodes';
import { ButtonsModule } from '@progress/kendo-angular-buttons';
import { AppComponent } from './app.component';
@NgModule({
imports: [ BrowserModule, BarcodesModule, ButtonsModule, FormsModule ],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
main.ts:
import './polyfills';
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app.module';
enableProdMode();
const platform = platformBrowserDynamic();
platform.bootstrapModule(AppModule);                
            
 QQ交談
QQ交談 在線咨詢
在線咨詢 
                 
                
 渝公網安備
            50010702500608號
渝公網安備
            50010702500608號
             
            
 客服熱線
客服熱線