Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7184299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:10:21+00:00 2026-05-28T18:10:21+00:00

I use the hsparql library to run a query that returns german text; and

  • 0

I use the hsparql library to run a query that returns german text; and thus iso-8859-1 special characters are returned.

I wrote the result of the query to a file using writeFile, but the special characters are not correctly shown. (when viewing the file with emacs)

When I instead write the output of the show function to a file, I get the following output:

["B\195\188ro", ...]

Printing out the special character it would mean: ["Büro", ....]

How can I write special characters correctly to a file? (e.g. “Büro” is correctly show in the file output.)

EDIT:
I know that show writes the escaped characters. Using writeFile directly doesn’t work, I have to check the link given in hammer’s answer to find a fix..

EDIT2:
removed, was the wrong approach.

EDIT3:
Hammers answer was right on the point. It took only 10 minutes to find the solution, but I needed to be fit and concentrated.

I looked up IO in link

The solution was (literate haskell):

> writeAllLabels = do

Running my Query (not shown, accesses the RDF TrippleStore):
>             res <- (selectStr33 (unlines qAllLabels))

>             outh <- openFile "/tmp/haskell_output.txt" WriteMode

this is the important line. If I would write "utf8" her instead of "latin1", I would get the wrong result again, i.e. as before asking the question...
>             hSetEncoding outh latin1

>             hPutStrLn outh res
>             hClose outh
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T18:10:21+00:00Added an answer on May 28, 2026 at 6:10 pm

    Don’t use show if you don’t want things escaped. It’s meant for lightweight serialization and will escape a number of special characters as well as characters outside the ASCII range. If you use writeFile directly, it should work with the default encoding for your current locale.

    For more fine-grained control over encodings, see the System.IO documentation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Use case: 3rd party application wants to programatically monitor a text file being generated
Use case: I've just entered insert mode, and typed some text. Now I want
use Rack::Static, :urls => ['/stylesheets', '/images'], :root => 'public' run proc { |env| [200,
We use a data acquisition card to take readings from a device that increases
use WWW::Mechanize; my $mech = WWW::Mechanize->new; $mech->get( $url ); say $mech->text; How could I
use pthread_create to create limited number of threads running concurrently Successfully compile and run
Use Case: End-User searches for something and an ArrayCollection is returned with Result objects.
Use scenario is pretty simple: I have a desktop only application that could be
use case example I have a servlet that is receiving login requests. If a
Use to work with a MySQL + + (library for C + +) The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.