Question

When a text value contains a newline, does SQLite on a Windows machine save the newline as 0x0D0A or as 0x0A?


Edit: I asked this question because I would like to know if this user defined sqlite function will return the right value if the passed string has a newline in it.

#!/use/bin/env perl
use DBI;
# ...
# ....
$dbh->sqlite_create_function( 'bit_length', 1, sub {
        use bytes;
        return length( $_[0] );
    }
);
Was it helpful?

Solution

SQLite does not change strings by itself; as long as you don't explicitly change them with some function, they are treated similar to blobs.

If you have a string like "Hello, world!\n" in your code, it will keep that newline style. If you read the text from a file, it depends on how your language handles newline conversions in text files, but there are not other places where Perl would implicitly convert newlines.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top