Convert a string literal AST node to Wtf8Buf, handling surrogate literals correctly.
(&self, string: &ast::ExprStringLiteral)
| 9401 | |
| 9402 | /// Convert a string literal AST node to Wtf8Buf, handling surrogate literals correctly. |
| 9403 | fn compile_string_value(&self, string: &ast::ExprStringLiteral) -> Wtf8Buf { |
| 9404 | let value = string.value.to_str(); |
| 9405 | if value.contains(char::REPLACEMENT_CHARACTER) { |
| 9406 | // Might have a surrogate literal; reparse from source to preserve them. |
| 9407 | string |
| 9408 | .value |
| 9409 | .iter() |
| 9410 | .map(|lit| { |
| 9411 | let source = self.source_file.slice(lit.range); |
| 9412 | crate::string_parser::parse_string_literal(source, lit.flags.into()) |
| 9413 | }) |
| 9414 | .collect() |
| 9415 | } else { |
| 9416 | value.into() |
| 9417 | } |
| 9418 | } |
| 9419 | |
| 9420 | fn compile_fstring_literal_value( |
| 9421 | &self, |