clarification of the .binary option of the sqlite3 command shell program.

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

clarification of the .binary option of the sqlite3 command shell program.

Graham Hardman
Hi,

I am curious about what this option does. It is not discussed in the
documentation and my own testing with the shell program has not aided my
understanding. A simple example would be nice.

regards,

Graham
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: clarification of the .binary option of the sqlite3 command shell program.

Jay Kreibich

> On Oct 19, 2018, at 3:30 AM, Graham Hardman <[hidden email]> wrote:
>
> Hi,
>
> I am curious about what this option does. It is not discussed in the
> documentation and my own testing with the shell program has not aided my
> understanding. A simple example would be nice.


It controls how data is output to files/stdout.

Only relevant on Windows; does absolutely nothing on all other platforms.

sqlite-amalgamation-3250200/shell.c:200:

/* On Windows, we normally run with output mode of TEXT so that \n characters
** are automatically translated into \r\n.  However, this behavior needs
** to be disabled in some cases (ex: when generating CSV output and when
** rendering quoted strings that contain \n characters).  The following
** routines take care of that.
*/
#if defined(_WIN32) || defined(WIN32)
static void setBinaryMode(FILE *file, int isOutput){
  if( isOutput ) fflush(file);
  _setmode(_fileno(file), _O_BINARY);
}
static void setTextMode(FILE *file, int isOutput){
  if( isOutput ) fflush(file);
  _setmode(_fileno(file), _O_TEXT);
}
#else
# define setBinaryMode(X,Y)
# define setTextMode(X,Y)
#endif





>
> regards,
>
> Graham
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: clarification of the .binary option of the sqlite3 command shell program.

Graham Hardman
thanks for that. I had forgotten about taking a look at the source code.
All clear now.
Graham

On 20-10-2018 12:29 am, Jay Kreibich wrote:

>> On Oct 19, 2018, at 3:30 AM, Graham Hardman <[hidden email]>
>> wrote:
>>
>> Hi,
>>
>> I am curious about what this option does. It is not discussed in the
>> documentation and my own testing with the shell program has not aided
>> my
>> understanding. A simple example would be nice.
>
>
> It controls how data is output to files/stdout.
>
> Only relevant on Windows; does absolutely nothing on all other
> platforms.
>
> sqlite-amalgamation-3250200/shell.c:200:
>
> /* On Windows, we normally run with output mode of TEXT so that \n
> characters
> ** are automatically translated into \r\n.  However, this behavior
> needs
> ** to be disabled in some cases (ex: when generating CSV output and
> when
> ** rendering quoted strings that contain \n characters).  The following
> ** routines take care of that.
> */
> #if defined(_WIN32) || defined(WIN32)
> static void setBinaryMode(FILE *file, int isOutput){
>   if( isOutput ) fflush(file);
>   _setmode(_fileno(file), _O_BINARY);
> }
> static void setTextMode(FILE *file, int isOutput){
>   if( isOutput ) fflush(file);
>   _setmode(_fileno(file), _O_TEXT);
> }
> #else
> # define setBinaryMode(X,Y)
> # define setTextMode(X,Y)
> #endif
>
>
>
>
>
>>
>> regards,
>>
>> Graham
>> _______________________________________________
>> sqlite-users mailing list
>> [hidden email]
>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users