一些信息:
运行时会发生什么
我得到预期的字符串"abcd"重复,直到它达到4094个字符的位置.之后所有输出都是这个标志"?" 直到文件结束.
我怎么看待这个?
我认为这不是预期的行为,它必定是某个地方的错误.
你可以测试的代码:
#include <iostream>
#include <fstream>
#include <locale>
#include <codecvt>
void createTestFile() {
std::ofstream file ("utf16le.txt", std::ofstream::binary);
if (file.is_open()) {
uint16_t bom = 0xFEFF; // UTF-16 little endian BOM
uint64_t abcd = 0x0064006300620061; // UTF-16 "abcd" string
file.write((char*)&bom,2);
for (size_t i=0; i<2000; i++) {
file.write((char*)&abcd,8);
}
file.close();
}
}
int main() {
//createTestFile(); // uncomment to make the test file
std::wifstream file;
std::wstring line;
file.open("utf16le.txt");
file.imbue(std::locale(file.getloc(), new std::codecvt_utf16<wchar_t, 0x10ffff, std::consume_header>));
if …
Run Code Online (Sandbox Code Playgroud) 我希望停止使用require()
以下模块的语句,因为 Node 版本 11 现在支持 ES6,但我找不到任何有关如何编写以下内容(除了express
作为import
语句)的文档:
import express from "express";
const http = require('http');
import bodyParser from 'body-parser';
const morgan = require('morgan');
Run Code Online (Sandbox Code Playgroud)
bodyParser
它与formorgan
和相同吗http
?
例如morgan
我只见过:
import logger from 'morgan';
因为http
我只看到:
import * as http from 'http';