aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Ingebrigtsen2019-12-24 17:11:04 +0100
committerLars Ingebrigtsen2019-12-24 17:11:11 +0100
commit0de63092c8ebae3877d97a18fa231c7ca2fbadc0 (patch)
treed0eb252cd7a15cf0bed6532631430a9ce2b7013a /src
parent6184aa003f44363e42762031ca368502021f9e7a (diff)
downloademacs-0de63092c8ebae3877d97a18fa231c7ca2fbadc0.tar.gz
emacs-0de63092c8ebae3877d97a18fa231c7ca2fbadc0.zip
Clarify base64 requirements and say what {en,de}code_coding_region does
* src/coding.c (Fencode_coding_region): Clarify what this does. (Fdecode_coding_region): Ditto. * src/fns.c (Fbase64_decode_region): Clarify that this function returns bytes, not text (bug#38587). (Fbase64_encode_region): Clarify that this function takes bytes, not text.
Diffstat (limited to 'src')
-rw-r--r--src/coding.c14
-rw-r--r--src/fns.c16
2 files changed, 28 insertions, 2 deletions
diff --git a/src/coding.c b/src/coding.c
index d9964908dce..35d6be470c8 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -9415,6 +9415,13 @@ code_convert_region (Lisp_Object start, Lisp_Object end,
9415DEFUN ("decode-coding-region", Fdecode_coding_region, Sdecode_coding_region, 9415DEFUN ("decode-coding-region", Fdecode_coding_region, Sdecode_coding_region,
9416 3, 4, "r\nzCoding system: ", 9416 3, 4, "r\nzCoding system: ",
9417 doc: /* Decode the current region from the specified coding system. 9417 doc: /* Decode the current region from the specified coding system.
9418
9419What's meant by \"decoding\" is transforming bytes into text
9420(characters). If, for instance, you have a region that contains data
9421that represents the two bytes #xc2 #xa9, after calling this function
9422with the utf-8 coding system, the region will contain the single
9423character ?\\N{COPYRIGHT SIGN}.
9424
9418When called from a program, takes four arguments: 9425When called from a program, takes four arguments:
9419 START, END, CODING-SYSTEM, and DESTINATION. 9426 START, END, CODING-SYSTEM, and DESTINATION.
9420START and END are buffer positions. 9427START and END are buffer positions.
@@ -9438,6 +9445,13 @@ not fully specified.) */)
9438DEFUN ("encode-coding-region", Fencode_coding_region, Sencode_coding_region, 9445DEFUN ("encode-coding-region", Fencode_coding_region, Sencode_coding_region,
9439 3, 4, "r\nzCoding system: ", 9446 3, 4, "r\nzCoding system: ",
9440 doc: /* Encode the current region by specified coding system. 9447 doc: /* Encode the current region by specified coding system.
9448
9449What's meant by \"encoding\" is transforming textual data (characters)
9450into bytes. If, for instance, you have a region that contains the
9451single character ?\\N{COPYRIGHT SIGN}, after calling this function with
9452the utf-8 coding system, the data in the region will represent the two
9453bytes #xc2 #xa9.
9454
9441When called from a program, takes four arguments: 9455When called from a program, takes four arguments:
9442 START, END, CODING-SYSTEM and DESTINATION. 9456 START, END, CODING-SYSTEM and DESTINATION.
9443START and END are buffer positions. 9457START and END are buffer positions.
diff --git a/src/fns.c b/src/fns.c
index 3ae3192b3d5..5e62d0e6f90 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -3297,7 +3297,13 @@ static Lisp_Object base64_encode_string_1 (Lisp_Object, bool,
3297DEFUN ("base64-encode-region", Fbase64_encode_region, Sbase64_encode_region, 3297DEFUN ("base64-encode-region", Fbase64_encode_region, Sbase64_encode_region,
3298 2, 3, "r", 3298 2, 3, "r",
3299 doc: /* Base64-encode the region between BEG and END. 3299 doc: /* Base64-encode the region between BEG and END.
3300Return the length of the encoded text. 3300The data in the region is assumed to represent bytes, not text. If
3301you want to base64-encode text, the text has to be converted into data
3302first by using `encode-coding-region' with the appropriate coding
3303system first.
3304
3305Return the length of the encoded data.
3306
3301Optional third argument NO-LINE-BREAK means do not break long lines 3307Optional third argument NO-LINE-BREAK means do not break long lines
3302into shorter lines. */) 3308into shorter lines. */)
3303 (Lisp_Object beg, Lisp_Object end, Lisp_Object no_line_break) 3309 (Lisp_Object beg, Lisp_Object end, Lisp_Object no_line_break)
@@ -3544,7 +3550,13 @@ base64_encode_1 (const char *from, char *to, ptrdiff_t length,
3544DEFUN ("base64-decode-region", Fbase64_decode_region, Sbase64_decode_region, 3550DEFUN ("base64-decode-region", Fbase64_decode_region, Sbase64_decode_region,
3545 2, 3, "r", 3551 2, 3, "r",
3546 doc: /* Base64-decode the region between BEG and END. 3552 doc: /* Base64-decode the region between BEG and END.
3547Return the length of the decoded text. 3553Return the length of the decoded data.
3554
3555Note that after calling this function, the data in the region will
3556represent bytes, not text. If you want to end up with text, you have
3557to call `decode-coding-region' afterwards with an appropriate coding
3558system.
3559
3548If the region can't be decoded, signal an error and don't modify the buffer. 3560If the region can't be decoded, signal an error and don't modify the buffer.
3549Optional third argument BASE64URL determines whether to use the URL variant 3561Optional third argument BASE64URL determines whether to use the URL variant
3550of the base 64 encoding, as defined in RFC 4648. */) 3562of the base 64 encoding, as defined in RFC 4648. */)