mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Punycode encoder/decoder: separate core and parts that depend on UTF8
encoder/decoder Swift SVN r20307
This commit is contained in:
@@ -27,17 +27,27 @@
|
||||
#include "swift/Basic/LLVM.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
|
||||
namespace swift {
|
||||
namespace Punycode {
|
||||
|
||||
/// Encodes a UTF-8-encoded Unicode string into Punycode.
|
||||
void encodePunycode(StringRef InputUTF8, std::string &OutPunycode);
|
||||
|
||||
/// Decodes a Punycode string into a UTF-8-encoded Unicode string.
|
||||
/// Encodes a sequence of code points into Punycode.
|
||||
///
|
||||
/// Returns true if the encoding failed, false if it succeeded.
|
||||
bool decodePunycode(StringRef InputPunycode, std::string &OutUTF8);
|
||||
/// Returns false if input contains surrogate code points.
|
||||
bool encodePunycode(const std::vector<uint32_t> &InputCodePoints,
|
||||
std::string &OutPunycode);
|
||||
|
||||
/// Decodes a Punycode string into a sequence of Unicode scalars.
|
||||
///
|
||||
/// Returns false if decoding failed.
|
||||
bool decodePunycode(StringRef InputPunycode,
|
||||
std::vector<uint32_t> &OutCodePoints);
|
||||
|
||||
bool encodePunycodeUTF8(StringRef InputUTF8, std::string &OutPunycode);
|
||||
|
||||
bool decodePunycodeUTF8(StringRef InputPunycode, std::string &OutUTF8);
|
||||
|
||||
} // end namespace Punycode
|
||||
} // end namespace swift
|
||||
|
||||
Reference in New Issue
Block a user