-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't escape non-ASCII characters in CSV data
By default, 'json.dumps' escapes escapes non-ASCII characters, which is undesirable for CSV data containing Unicode characters. This commit causes all characters to be output as-is. Addresses: #100
- Loading branch information
Showing
1 changed file
with
15 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,29 @@ | ||
#! /usr/bin/python3 | ||
|
||
# SMS Import / Export: a simple Android app for importing and exporting SMS messages from and to JSON files. | ||
# Copyright (c) 2023 Thomas More | ||
# SMS Import / Export: a simple Android app for importing and exporting SMS and | ||
# MMS messages, call logs, and contacts, from and to JSON / NDJSON files. | ||
# | ||
# Copyright (c) 2023, 2025 Thomas More | ||
# | ||
# This file is part of SMS Import / Export. | ||
# | ||
# SMS Import / Export is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# it under the terms of the GNU General Public License as published by the Free | ||
# Software Foundation, either version 3 of the License, or (at your option) any | ||
# later version. | ||
# | ||
# SMS Import / Export is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# SMS Import / Export is distributed in the hope that it will be useful, but | ||
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
# details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with SMS Import / Export. If not, see <https://www.gnu.org/licenses/>. | ||
# You should have received a copy of the GNU General Public License along with | ||
# SMS Import / Export. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
# Written for https://github.com/tmo1/sms-ie/issues/100 | ||
|
||
import csv | ||
import json | ||
|
||
print(json.dumps(list(csv.DictReader(open(0, newline=''))), indent=2)) | ||
print(json.dumps(list(csv.DictReader(open(0, newline=''))), indent=2, ensure_ascii=False)) | ||
|