Commit Graph

34 Commits

Author SHA1 Message Date
Kirill Elagin
f9aea084bb troubleshoot: Show listing locale-archive early
In case something bad happens with `localedef --list`, print the header
early to make it clear what failed.
Also, print the exception, if it happened.
2020-05-15 16:22:53 +03:00
Kirill Elagin
b5451aa606 utf8-troubleshoot: Only show relevant env vars 2020-05-15 16:22:53 +03:00
Kirill Elagin
e595be6575 utf8-troubleshoot: Update Changelog 2020-05-15 16:22:53 +03:00
Kirill Elagin
6626507c16 troubleshoot: Add C stuff 2020-05-15 16:22:53 +03:00
Kirill Elagin
4074fe8f8d troubleshoot: Improve locale detection
* Use `localectl list-locales` if possible.
* Otherwise list `/usr/lib/locale` and try to use `localedef` to list
  `/usr/lib/locale/locale-archive`.
* Do not bother with `/usr/share/locale` as, it turns out, it is only used
  for localisations by third-party programs on Linux. Strangely, macOS
  seems to have actual locale definitions in there, but this tool is
  mostly aimed at Linux, since macOS installations are pretty uniform.
2020-04-21 14:05:53 +03:00
Kirill Elagin
976e81391a Release v1.0.1.0 2020-04-21 02:19:08 +03:00
Kirill Elagin
28a16678d5 Bump base for GHC 8.10 2020-04-21 02:15:19 +03:00
Kirill Elagin
bf51f1208b troubleshoot: Show basic system info 2020-04-21 01:51:15 +03:00
Kirill Elagin
b42026b313 troubleshoot: Make the troubleshooting tool 2020-04-21 01:40:36 +03:00
Kirill Elagin
380afc64d4 Release v1.0.0.0 2020-03-04 00:06:35 -05:00
Kirill Elagin
5344dd7654 Add upper bounds on library deps 2020-02-26 22:46:45 -05:00
Kirill Elagin
d364dcf52c Relax bound on base (allow 8.2 and 8.8) 2020-02-26 22:46:31 -05:00
Kirill Elagin
f1407c5e7a meta: Rename to with-utf8 2020-02-26 22:00:59 -05:00
Kirill Elagin
6aa91803d8 Remove license header from README
* Move README licensing information to .reuse/dep5
  to make Hackage happy (it doesn’t know to ignore HTML comments
  in Markdown).
2020-02-18 00:35:32 -05:00
Kirill Elagin
ad3837c595 cabal: Update metainfo
* Add dependency version bounds for the library
* Add category
2020-02-18 00:32:12 -05:00
Kirill Elagin
7cab5d1b7c Update documentation
* Add links to the prospective blog post everywhere.
* Fix tiny issues.
* Add package description for Hackage.
2020-02-17 20:00:13 -05:00
Kirill Elagin
c68db4da46 Merge branch 'kirelagin/do-not-change-std' 2020-02-17 19:41:01 -05:00
Kirill Elagin
0744864fd0 Fixup documentation 2020-02-17 19:39:55 -05:00
Kirill Elagin
40069d4b2b Allow not changing file handles to UTF-8
The old interface only allowed one to perform terminal detection on a
handle and change it to UTF-8 if it was not a terminal. Turns our, it
makes sense to sometimes leave the original encoding on a handle even if
it does not point to a terminal.

* Change the interface to separate these two use-cases.
* Extract main-wrappers to a new `Main` module.
2020-02-17 19:39:40 -05:00
Kirill Elagin
8a76bb2577 Add test for a binary terminal 2020-02-17 17:58:29 -05:00
Kirill Elagin
93bf56ea57 test: Use a pseudo-terminal for testing
Previously the code was using stdout for testing the terminal detection
functionality. However, there is no guarantee that the tests will always
be running with stdout attached to a terminal.

Create a fresh pseudo-terminal instead and use it instead of stdout.
2020-02-17 17:58:29 -05:00
Kirill Elagin
f6bc3fc0ca Add correctness tests
* Split out the actual encoding choice logic into a separate Internal
  module to make it possible to cover it with tests.
* Make this function a little more efficient compared to the previous
  purely pure function.
* Keep a completely pure function as a specficiation for ease of reading
  and for testing by comparing the actualy function to the pure one.

* Add tests that check that the pure function makes sense.
* Add tests that compare the output of the real function to the output
  of the pure function on some real handles.
* Add tests that check that functions that are supposed to actually
  modify the encoding of a handle actually do modify it.
2020-02-17 17:58:29 -05:00
Kirill Elagin
59af11bc28
Merge pull request #2 from serokell/kirelagin/haskell-nix
Build with haskell.nix
2020-02-17 17:57:31 -05:00
Kirill Elagin
5cce9dcbd2
Merge pull request #1 from serokell/kirelagin/first-version
[INT-146] First version imported from nixfmt
2020-02-17 17:57:12 -05:00
Kirill Elagin
83f7b5967e Add lazy versions of Text functions
We had `readFile` and `writeFile` fot strict `Text`, but not for
lazy.

Add lazy versions of the same functions, basically, by copy-pasting.
2020-02-17 17:53:04 -05:00
Kirill Elagin
5b98b490bc Implement hWithEncoding
This function allows one to not only safely set the best encoding on a
file descriptor, but also restore the previous one. The idea is that it
will be used on file descriptors that come from the outside and so we
don’t know how they were used and will be used after us.
2020-02-16 21:49:07 -05:00
Kirill Elagin
35e2ea5ce2 Add missing CHANGELOG entry
The changelog entry for `hSetEncoding` was missing.

Add it.
2020-02-16 21:48:20 -05:00
Kirill Elagin
934251c90c Change hSetEncoding to choose best encoding
The previous version of hSetEncoding would always set UTF-8.
This can screw things up if it is accidentally called, for example,
on a terminal handle or a handle in binary mode.

Change it to use `hSetBestUtf8Enc` internally so that it now follows the
same loginc in determining the encoding to set.
2020-02-16 21:46:33 -05:00
Kirill Elagin
7b33f6743b Remove obsolete import 2020-02-16 21:08:41 -05:00
Kirill Elagin
2a63a74c0c fixup: Remove unused module 2020-02-15 23:41:24 -05:00
Kirill Elagin
cd67a3183e Build with haskell.nix 2020-02-15 21:32:39 -05:00
Kirill Elagin
15acfcf9c6 Add missing licensing information 2020-02-15 21:12:08 -05:00
Kirill Elagin
08407bbe4d First version 2020-02-15 19:15:52 -05:00
Kirill Elagin
b7b3ef4bc5 Initialise repository 2020-02-15 19:08:31 -05:00