gbk2utf8 1.0.1
gbk2utf8 #
A flutter package to convert gbk to utf-8
目的 #
现在这个版本官方的http还不能支持中文gbk的解析,这个项目就是为了解决这个问题
目前这个库已经成熟,类似flutter原有的utf8编码调用,即为gbk.encode和gbk.decode这两个方法进行转化。 如果还有不懂的地方,可以入群854192563讨论.
使用方法 #
增加依赖
gbk2utf8: ^1.0.0
String转gbk流用以上传服务器 #
gbk.encode("需要转gbk的中文");
注意转化后的结果是List
gbk流转String #
gbk.decode(gbk二进制流,一般是http的response);
例子:解析中文html #
编写代码
void download() async {
try {
http.Response response =
await http.get("http://www.ysts8.com/index_hot.html");
String data = gbk.decode(response.bodyBytes);
setState(() {
_text = data;
});
} catch (e) {
setState(() {
_text = "网络异常,请检查";
});
}
}
完整代码在
效果:
[1.0.1]
Better document
[1.0.0]
Change api to gbk.encode and gbk.decode
[0.0.3]
- Format code.
[0.0.2]
- upgrade sdk version
[0.0.1]
- basic usage
example #
A new Flutter project.
Getting Started #
For help getting started with Flutter, view our online documentation.
Use this package as a library
1. Depend on it
Add this to your package's pubspec.yaml file:
dependencies:
gbk2utf8: ^1.0.1
2. Install it
You can install packages from the command line:
with Flutter:
$ flutter pub get
Alternatively, your editor might support flutter pub get
.
Check the docs for your editor to learn more.
3. Import it
Now in your Dart code, you can use:
import 'package:gbk2utf8/gbk2utf8.dart';
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
82
|
Health:
Code health derived from static analysis.
[more]
|
93
|
Maintenance:
Reflects how tidy and up-to-date the package is.
[more]
|
82
|
Overall:
Weighted score of the above.
[more]
|
85
|
We analyzed this package on Dec 5, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
- Dart: 2.6.1
- pana: 0.12.21
- Flutter: 1.9.1+hotfix.6
Platforms
Detected platforms: Flutter
References Flutter, and has no conflicting libraries.
Health suggestions
Fix lib/src/convert.dart
. (-4.41 points)
Analysis of lib/src/convert.dart
reported 9 hints, including:
line 75 col 30: Name non-constant identifiers using lowerCamelCase.
line 82 col 33: Name non-constant identifiers using lowerCamelCase.
line 83 col 7: Name non-constant identifiers using lowerCamelCase.
line 83 col 20: Name non-constant identifiers using lowerCamelCase.
line 83 col 33: Name non-constant identifiers using lowerCamelCase.
Fix lib/src/gbk.dart
. (-1.49 points)
Analysis of lib/src/gbk.dart
reported 3 hints:
line 1 col 5: Name non-constant identifiers using lowerCamelCase.
line 2 col 5: Name non-constant identifiers using lowerCamelCase.
line 3 col 5: Name non-constant identifiers using lowerCamelCase.
Fix lib/src/unicode.dart
. (-1.49 points)
Analysis of lib/src/unicode.dart
reported 3 hints:
line 1 col 5: Name non-constant identifiers using lowerCamelCase.
line 2 col 5: Name non-constant identifiers using lowerCamelCase.
line 3 col 5: Name non-constant identifiers using lowerCamelCase.
Format lib/gbk2utf8.dart
.
Run flutter format
to format lib/gbk2utf8.dart
.
Maintenance suggestions
The package description is too short. (-18 points)
Add more detail to the description
field of pubspec.yaml
. Use 60 to 180 characters to describe the package, what it does, and its target use case.
Dependencies
Package | Constraint | Resolved | Available |
---|---|---|---|
Direct dependencies | |||
Dart SDK | >=2.0.0-dev.68.0 <3.0.0 | ||
flutter | 0.0.0 | ||
Transitive dependencies | |||
collection | 1.14.11 | 1.14.12 | |
meta | 1.1.7 | 1.1.8 | |
sky_engine | 0.0.99 | ||
typed_data | 1.1.6 | ||
vector_math | 2.0.8 | ||
Dev dependencies | |||
flutter_test |