问题标签 [wofstream]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
c++ - Write encrypted wstring to wofstream
I have a simple "encryption" function that works with wstring
variables and I want to write the result of this function into a file, using wofstream
.
This is my code:
So, the problem with this piece of ... code is that although the wprintf_s
function outputs the entire encrypted text, in the written file I only see the characters inside the ASCII range (or at least is what it seems to me). The encrypted text is saved until an unknown character is found (displayed by ? in the console). I want to save any character, and I want them saved as wide chars (1 word each one). How can I do this?
c++ - C++ 不保存 UTF-8 编码文件
我正在使用需要保存带有特殊字符(如“çäüëé”)的 utf-8 文件的软件。
我从 Web 服务(使用 gsoap)收到要保存的内容(带有特殊字符编码的常规字符串)。当我尝试使用 ofstream 保存时,该文件会保存一个正方形和其他奇怪的字符,而不是特殊字符。
当我尝试将常规字符串转换为宽字符串时,它丢失了特殊字符(它被不同的字符替换)。并且,使用 wofstream,当有特殊字符时,文件不会保存文件。
我也尝试使用 utf8-cpp,但它的文件也写不正确。
c++ - 标准 C++ 中的事务文件保存
是否可以在标准 C++ 中实现事务文件保存而不使用系统特定的 API 调用,如,CopyFile
等。ReplaceFile
CreateFile
目前我正在这样做(使用 Win32 API 特定代码):
有没有一种方法可以在不使用 Win32 API 特定函数(即标准库或 boost)的情况下实现类似的事情?
c++ - 使用流将类对象写入文件
我有这个代码来序列化/反序列化类对象到文件,它似乎工作。但是,我有两个问题。
- 如果我想在我的班级中有一个和一个成员变量,而不是两个
wstring
(就像我现在一样)怎么办?(我认为在这种情况下我的代码不起作用?)。wstring
string
- 最后,在下面,主要是,当我初始化
s2.product_name_= L"megatex";
if 而不是 megatex 我用俄语写一些东西时(例如,s2.product_name_= L"логин"),代码不再按预期工作。
有什么问题?谢谢。
这是代码:
c++ - Ustring 错误(打印期间)
我想将 UTF-8 文件解析为 ustring,我在 str 中读取了这个文件。有一个错误:在抛出 'Glib::ConvertError' 的实例后调用终止。我应该怎么办?
c++ - using wregex creates garbage output?
I created a simple program using regex to tokenize a file. For nonUnicode content it works fine. For a Unicode based content I made a wregex version but this version creates garbage output!
I am trying to output Unicode characters or strings on a console screen instead I stored them in a map<wstring,int>
and a file of type wostream so that the values are intact and correct.
After running the application the file containing the extracted tokens, contain just garbage!!!
Whats wrong with this program and how can I fix it?
#xA;This is the content of ftest.txt
:
And this is the garbage output inside list.txt
c++11 - 如何在 shared_ptr 之间进行转换到 C++ 中的文件 *?
我试图在我的应用程序中多次使用 FILE 指针,尽管我创建了一个函数并将指针传递给它。基本上我有这段代码
这是重复的,现在我想要这样的东西:
和功能:
这不简单。我尝试使用&*fp
而不是,fp.get()
但仍然没有运气。
c++ - 如何将非英语字符串写入文件并使用 C++ 从该文件中读取?
我想将 a 写入std::wstring
文件并需要将该内容读取为std:wstring
. 当字符串为L"<Any English letter>"
. 但是当我们有孟加拉语、卡纳达语、日语等任何类型的非英语字母时,问题就出现了。尝试了各种选项,例如:
- 将文件转换
std::wstring
为std::string
并写入文件以及读取时间读取为std::string
并转换为std::wstring
- 正在写作(我可以从编辑中看到)但阅读时间出现错误的字符
- 写入
std::wstring
wofstream,这也无助于母语字符字母,例如std::wstring data = L"হ্যালো ওয়ার্ল্ড";
平台是mac和Linux,语言是C++
代码:
c++ - 为什么 std::wofstream 不将所有 wstring 打印到文件中?
我有一个std::wstring
大小为 139,580,199 个字符的字符。
为了调试,我使用以下代码将其打印到文件中:
之后注意到字符串的结尾丢失了。创建的文件大小为 109,592,584 字节(“磁盘大小”为 109,596,672 字节)。
还检查缓冲区是否包含空字符,这样做:
期望结果是,std::wstring::npos
但它是18446744073709551615
,但我的字符串最后没有空字符,所以可能没关系。
有人可以解释一下,为什么我没有将所有字符串都打印到文件中?
c++ - 使用 wofstream 时 C++ 未解析的外部符号
我正在从批处理文件编译和链接此源代码,而我现在正在导入的库是MSVCRT.LIB Kernel32.lib User32.lib
代码在我包含string
iostream
并fstream
创建一些wofstream
对象之前一直有效。那时链接器向我显示了大量未解析的符号,其中:
所以我想知道我可能会缺少哪些库。在链接器中,我指定了/nodefaultlib
选项,因此我可以决定使用哪些库,但现在我遇到了这个问题,找不到这些标准函数的库。