diff options
| author | Richard M. Stallman | 2003-07-22 15:18:32 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2003-07-22 15:18:32 +0000 |
| commit | 582ef186ea8ed5d6a6718f09bff92e6a756c7f9d (patch) | |
| tree | aad387c149bb39a2b5268dd5ab343af357ebeca5 | |
| parent | 75442b3f4306851019cbe7f9bdf8a52669433e97 (diff) | |
| download | emacs-582ef186ea8ed5d6a6718f09bff92e6a756c7f9d.tar.gz emacs-582ef186ea8ed5d6a6718f09bff92e6a756c7f9d.zip | |
(Decoding Output): New node.
| -rw-r--r-- | lispref/processes.texi | 75 |
1 files changed, 53 insertions, 22 deletions
diff --git a/lispref/processes.texi b/lispref/processes.texi index 159ed47c059..39feaa68a4c 100644 --- a/lispref/processes.texi +++ b/lispref/processes.texi | |||
| @@ -898,29 +898,11 @@ you want to keep the output to those streams separate, you should | |||
| 898 | redirect one of them to a file--for example, by using an appropriate | 898 | redirect one of them to a file--for example, by using an appropriate |
| 899 | shell command. | 899 | shell command. |
| 900 | 900 | ||
| 901 | Subprocess output is normally decoded using a coding system before the | ||
| 902 | buffer or filter function receives it, much like text read from a file. | ||
| 903 | You can use @code{set-process-coding-system} to specify which coding | ||
| 904 | system to use (@pxref{Process Information}). Otherwise, the coding | ||
| 905 | system comes from @code{coding-system-for-read}, if that is | ||
| 906 | non-@code{nil}; or else from the defaulting mechanism (@pxref{Default | ||
| 907 | Coding Systems}). | ||
| 908 | |||
| 909 | @strong{Warning:} Coding systems such as @code{undecided} which | ||
| 910 | determine the coding system from the data do not work entirely reliably | ||
| 911 | with asynchronous subprocess output. This is because Emacs has to | ||
| 912 | process asynchronous subprocess output in batches, as it arrives. Emacs | ||
| 913 | must try to detect the proper coding system from one batch at a time, | ||
| 914 | and this does not always work. Therefore, if at all possible, use a | ||
| 915 | coding system which determines both the character code conversion and | ||
| 916 | the end of line conversion---that is, one like @code{latin-1-unix}, | ||
| 917 | rather than @code{undecided} or @code{latin-1}. | ||
| 918 | |||
| 919 | @menu | 901 | @menu |
| 920 | * Process Buffers:: If no filter, output is put in a buffer. | 902 | * Process Buffers:: If no filter, output is put in a buffer. |
| 921 | * Filter Functions:: Filter functions accept output from the process. | 903 | * Filter Functions:: Filter functions accept output from the process. |
| 922 | * Accepting Output:: Explicitly permitting subprocess output. | 904 | * Decoding Ouptut:: Filters can get unibyte or multibyte strings. |
| 923 | Waiting for subprocess output. | 905 | * Accepting Output:: How to wait until process output arrives. |
| 924 | @end menu | 906 | @end menu |
| 925 | 907 | ||
| 926 | @node Process Buffers | 908 | @node Process Buffers |
| @@ -1162,6 +1144,55 @@ there is no filter function: | |||
| 1162 | @end smallexample | 1144 | @end smallexample |
| 1163 | @end ignore | 1145 | @end ignore |
| 1164 | 1146 | ||
| 1147 | @node Decoding Output | ||
| 1148 | @subsection Decoding Process Output | ||
| 1149 | |||
| 1150 | When Emacs writes process output directly into a multibyte buffer, | ||
| 1151 | it decodes the output according to the process output coding system. | ||
| 1152 | If the coding system is @code{raw-text} or @code{no-conversion}, Emacs | ||
| 1153 | converts the unibyte output to multibyte using | ||
| 1154 | @code{string-to-multibyte}, inserts the resulting multibyte text. | ||
| 1155 | |||
| 1156 | You can use @code{set-process-coding-system} to specify which coding | ||
| 1157 | system to use (@pxref{Process Information}). Otherwise, the coding | ||
| 1158 | system comes from @code{coding-system-for-read}, if that is | ||
| 1159 | non-@code{nil}; or else from the defaulting mechanism (@pxref{Default | ||
| 1160 | Coding Systems}). | ||
| 1161 | |||
| 1162 | @strong{Warning:} Coding systems such as @code{undecided} which | ||
| 1163 | determine the coding system from the data do not work entirely | ||
| 1164 | reliably with asynchronous subprocess output. This is because Emacs | ||
| 1165 | has to process asynchronous subprocess output in batches, as it | ||
| 1166 | arrives. Emacs must try to detect the proper coding system from one | ||
| 1167 | batch at a time, and this does not always work. Therefore, if at all | ||
| 1168 | possible, specify a coding system that determines both the character | ||
| 1169 | code conversion and the end of line conversion---that is, one like | ||
| 1170 | @code{latin-1-unix}, rather than @code{undecided} or @code{latin-1}. | ||
| 1171 | |||
| 1172 | @cindex filter multibyte flag, of process | ||
| 1173 | @cindex process filter multibyte flag | ||
| 1174 | When Emacs calls a process filter function, it provides the process | ||
| 1175 | output as a multibyte string or as a unibyte string according to the | ||
| 1176 | process's filter multibyte flag. If the flag is non-@code{nil}, Emacs | ||
| 1177 | decodes the output according to the process output coding system to | ||
| 1178 | produce a multibyte string, and passes that to the process. If the | ||
| 1179 | flag is @code{nil}, Emacs puts the output into a unibyte string, with | ||
| 1180 | no decoding, and passes that. | ||
| 1181 | |||
| 1182 | When you create a process, the filter multibyte flag takes its | ||
| 1183 | initial value from @code{default-enable-multibyte-characters}. If you | ||
| 1184 | want to change the flag later on, use | ||
| 1185 | @code{set-process-filter-multibyte}. | ||
| 1186 | |||
| 1187 | @defun set-process-filter-multibyte process multibyte | ||
| 1188 | This function sets the filter multibyte flag of @var{process} | ||
| 1189 | to @var{multibyte}. | ||
| 1190 | @end defun | ||
| 1191 | |||
| 1192 | @defun process-filter-multibyte-p process | ||
| 1193 | This function returns the filter multibyte flag of @var{process}. | ||
| 1194 | @end defun | ||
| 1195 | |||
| 1165 | @node Accepting Output | 1196 | @node Accepting Output |
| 1166 | @subsection Accepting Output from Processes | 1197 | @subsection Accepting Output from Processes |
| 1167 | 1198 | ||