'Haskell new line character

I need to compare Windows new line character ('\r\n') but I get

lexical error in string/character literal at character '\\'

['\r\n']

How can I solve this?

Thanks!



Solution 1:[1]

Note that for files/streams in the default text mode on Windows, "\r\n" is automatically converted to "\n" on input, and vice versa on output.

If you have special needs that the default doesn't handle, you may wish to look into the System.IO.hSetNewlineMode function, which allows you to set the newline conversion used for a specific handle. For example:

hSetNewlineMode handle universalNewlineMode

sets a handle to accept either "\r\n" or "\n" as newline (internally "\n") on input, but uses the native OS convention on output.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1