我有一个像这样的json文件
{"downloads":[
{
"url":"arquivo1.pdf",
"descricao":"árquivo 1"
},
{
"url":"arquivo2.pdf",
"descricao":"arquivo 2"
}
]}
Run Code Online (Sandbox Code Playgroud)
我通过Notepad ++使用UTF-8编码保存它.
然后我得到文件内容:
function getContent($name)
{
$content = file_get_contents("configs/" . $name . ".json");
$encoded = utf8_encode($content);
return json_decode($encoded);
}
Run Code Online (Sandbox Code Playgroud)
并json_decode返回null.
如果我将json文件保存为ANSI,那么它可以工作.但是我想把它保存为UTF-8.
我不想按下ESC更改为正常模式,所以我写了一个小脚本,为我做了一段时间后.但是我收到以下错误:
Error detected while processing InsertEnter Auto commands for "*":
E521: Number required after =: updatetime=aunm
Run Code Online (Sandbox Code Playgroud)
这是脚本
let aunm=800
au InsertEnter * let aunm_restore=&updatetime | set updatetime=aunm | au CursorHoldI * :stopinsert
au InsertLeave * let &updatetime=aunm_restore
Run Code Online (Sandbox Code Playgroud)
如果我删除let aunm=800并设置manualy set updatetime=800它完美的工作.但我希望有一个全局变量来改变时间,如果需要的话.
我有这个功能
TOKENP scan_line() {
TOKENP cur, last = 0;
while(cur = scan_opd())
last = cur;
if (cur = scan_comm())
#if ENABLE_COMMENT_AS_TOKEN
add_token(cur);
#endif
return last;
}
Run Code Online (Sandbox Code Playgroud)
如果#if指令为false,则将其编译为
if (cur = scan_comm())
return last;
Run Code Online (Sandbox Code Playgroud)
要么
if (cur = scan_comm());
return last;
Run Code Online (Sandbox Code Playgroud)
?
我不知道这是否可能,即使它是正确的,但我在.c文件中定义了一个宏,现在我想要公开该宏,所以我需要把它放在.h文件中.但我不想揭露它是如何实现的,只是要使用的签名.
//.c
#define sayhi() printf("hi");
//.h
sayhi()
//another.c
int main(...) {
sayhi();
}
Run Code Online (Sandbox Code Playgroud) 我有这样的自定义AuthorizeAttribute
public class DevMode : AuthorizationFilterAttribute
{
public override void OnAuthorization(HttpActionContext actionContext)
{
if (myConditionToAuthorize)
{
// how to allow [Authorize] ?
}
}
}
Run Code Online (Sandbox Code Playgroud)
问题是它与[Authorize]标签一起使用,如下所示:
[Authorize, DevMode]
public class UserController : ApiController { ... }
Run Code Online (Sandbox Code Playgroud)
我需要让[Authorize] == true内心[DevMode]
或者最好将它们放在一个独特的授权类中?但后来我不知道检查授权数据.
我想在数组中查找特定的类类型.不知道怎么样.
var a:A = new A();
var b:B = new B(); // B extends A
var c:C = new C(); // C extends A
var arr:Array<A> = [];
arr.push(a);
arr.push(b);
arr.push(c);
// i'd like something like:
c = arr.get<C>();
Run Code Online (Sandbox Code Playgroud) 我想要一个删除/添加引号的命令
"This is a text" -> This is a text
This is a text -> "This is a text"
Run Code Online (Sandbox Code Playgroud)
有一些吗?
我想创建一个自定义的AuthorizeAttribute那
不知道怎么办.我的意思是,如何访问属性中的用户信息以进行检查?
为什么我不能在javascript中这样做:
var log = console.log;
log(123);
Run Code Online (Sandbox Code Playgroud)
以及如何实现这一目标?
long *video_memory = (long *)0xB8000;
int main() {
// long *video_memory = (long *)0xB8000;
*video_memory = 0x5050505050505050;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
为什么当我链接它时,上面的这个 C 代码会创建一个2Mb 的二进制文件?
如果我注释全局变量并取消注释它的本地变量(文件只有几个字节)。
这就是我链接/[交叉]编译它的方式:
x86_64-elf-gcc -m64 -ffreestanding -nostdlib -mno-red-zone -c kernel.c -o bin/kernel.o
objcopy --remove-section .eh_frame bin/kernel.o
x86_64-elf-ld --oformat binary -Ttext 0x8000 bin/kernel_entry.o bin/kernel.o -o bin/kernel.bin
# kernel.bin is now 2Mb
Run Code Online (Sandbox Code Playgroud)