String:WriteUtf8: Add REPLACE_INVALID_UTF8 option
authordcarney@chromium.org <dcarney@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 20 Jan 2014 09:52:54 +0000 (09:52 +0000)
committerdcarney@chromium.org <dcarney@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 20 Jan 2014 09:52:54 +0000 (09:52 +0000)
commitf93f8ded96365c29a60bc79175286e9bbe799fcf
tree76b7749987b09f60d9e0e8d8e6fb2f4ac4320fb2
parent04b1baa4c48b2b1060e1b9456c4254ea7b7b7b9b
String:WriteUtf8: Add REPLACE_INVALID_UTF8 option

This patch makes String::WriteUtf8 replace invalid code points (i.e. unmatched
surrogates) with the unicode replacement character when REPLACE_INVALID_UTF8 is
set.  This is done to avoid creating invalid UTF-8 output which can lead to
compatibility issues with software requiring valid UTF-8 inputs (e.g. the
WebSocket protocol requires valid UTF-8 and terminates connections when invalid
UTF-8 is encountered).

R=dcarney@chromium.org

BUG=

Review URL: https://codereview.chromium.org/121173009

Patch from Felix Geisendörfer <haimuiba@gmail.com>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18683 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
include/v8.h
src/api.cc
src/unicode-inl.h
src/unicode.h
test/cctest/test-api.cc