mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
fix: replace String.fromCharCodes with utf8.decode for proper Chinese character handling in JSON import (#874)
This commit is contained in:
@@ -360,7 +360,13 @@ final class _BackupPageState extends ConsumerState<BackupPage> with AutomaticKee
|
||||
onTap: () async {
|
||||
final data = await context.showImportDialog(title: l10n.snippet, modelDef: Snippet.example.toJson());
|
||||
if (data == null) return;
|
||||
final str = String.fromCharCodes(data);
|
||||
String str;
|
||||
try {
|
||||
str = utf8.decode(data);
|
||||
} on FormatException catch (e, s) {
|
||||
context.showErrDialog(e, s, libL10n.error);
|
||||
return;
|
||||
}
|
||||
final (list, _) = await context.showLoadingDialog(
|
||||
fn: () => Computer.shared.start((s) {
|
||||
return json.decode(s) as List;
|
||||
@@ -588,7 +594,13 @@ extension on _BackupPageState {
|
||||
void _onBulkImportServers(BuildContext context) async {
|
||||
final data = await context.showImportDialog(title: l10n.server, modelDef: Spix.example.toJson());
|
||||
if (data == null) return;
|
||||
final text = String.fromCharCodes(data);
|
||||
String text;
|
||||
try {
|
||||
text = utf8.decode(data);
|
||||
} on FormatException catch (e, s) {
|
||||
context.showErrDialog(e, s, libL10n.error);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
final (spis, err) = await context.showLoadingDialog(
|
||||
|
||||
Reference in New Issue
Block a user