commit 4d504d613af09c41edadcf36c5f7643d280cf138
parent 0320de84a7c53bb482bd71756467b1e62e5b8d92
Author: Jan Pobrislo <ccx@webprojekty.cz>
Date: Mon, 29 Feb 2016 15:15:42 +0100
force utf8 encoding in prolog script
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/query.pl b/query.pl
@@ -1,7 +1,7 @@
#!/usr/bin/env swipl
% vim: ft=prolog textwidth=80 tabstop=4 softtabstop=4 shiftwidth=4 expandtab
-:- use_module(library(pure_input)).
+%% :- use_module(library(pure_input)).
%%% :- use_module(library(dcg/basics)).
:- initialization main.
@@ -155,7 +155,7 @@ out_default_aux([]) --> [].
parse_file(InFile) :-
- ( open(InFile, read, Fd), read_stream_to_codes(Fd, Codes)
+ ( open(InFile, read, Fd, [encoding(utf8)]), read_stream_to_codes(Fd, Codes)
-> true
; throw(read_error(InFile))
),
@@ -169,6 +169,8 @@ parse_file(InFile) :-
-> true
; throw(formatting_failed(InFile,Awk))
),
+ current_stream(1, write, OutStream),
+ set_stream(OutStream, encoding(utf8)),
format('~s', [Out]).
main :- current_prolog_flag(argv, Argv), main(Argv).