Open
Description
Consider two .sql scripts from attached .zip file.
sql-check-EOL-handling_-_linux-vs-windows.zip
File "check-linux-line-EOL.sql" was created in Linux text editor (one that built-in in mc) and, of couse, has appropriate EOL characters = ascii_char(10):
File "check-windows-line-EOL.sql" was created in Windows and has EOL = concatenated ascii_char(13) and ascii_char(10):
Now run this scriprs in corresponding OS.
On Linux output will be expected:
select ascii_val( '
' )
from rdb$database;
10
-------------------------------------------------------
select char_length( '
' )
from rdb$database;
1
-------------------------------------------------------
select ascii_char(10) = '
'
from rdb$database;
<true>
-------------------------------------------------------
select '
' = ascii_char(10)
from rdb$database;
<true>
-------------------------------------------------------
select trim('
') = trim(ascii_char(10))
from rdb$database;
<true>
On Windows output shows that ASCII_CHAR() ignores first character of EOL that is used on that OS, i.e. chr(13).
And we get wrong results for all statements of this script:
select ascii_val( '
' )
from rdb$database;
10 ---------------- ?? why not 13 ??
-------------------------------------------------------
select char_length( '
' )
from rdb$database;
1 --------------------- ?? why not 2 ??
-------------------------------------------------------
select ascii_char(13) || ascii_char(10) = '
'
from rdb$database;
<false>
-------------------------------------------------------
select '
' = ascii_char(13) || ascii_char(10)
from rdb$database;
<false>
PS.
Checked on 6.0.0.765
Metadata
Metadata
Assignees
Labels
No labels