================
@@ -114,6 +115,31 @@ inline ErrorOr<bool> needConversion(const Twine &FileName,
const int FD = -1) {
return false;
}
+inline ErrorOr<SmallString<32>>
+getEncodingNameFromFileTag(const Twine &FileName, const int FD = -1) {
+#ifdef __MVS__
+ ErrorOr<__ccsid_t> TagOrErr = getzOSFileTag(FileName, FD);
+ if (!TagOrErr)
+ return TagOrErr.getError();
+
+ __ccsid_t Tag = *TagOrErr;
+ if (Tag == 0)
+ return SmallString<32>(); // Return empty string for no tag
+
+ if (Tag == 1208)
+ return SmallString<32>("utf-8");
+
+ if (Tag == 1047)
+ return SmallString<32>("ibm-1047");
+
+ SmallString<32> Result;
+ raw_svector_ostream(Result) << Tag;
+ return Result;
----------------
hubert-reinterpretcast wrote:
> * UCS2, UTF-16, UTF32 should be mapped to empty string - I don't think we
> have any desire to support double width input encodings.
Considering that we are talking about the source encoding (not the literal
encoding), this seems a bit arbitrary to me. I think this needs to be a point
of discussion on the RFC (please bring it up if I forget).
https://github.com/llvm/llvm-project/pull/206519
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits