小编Gus*_*Gus的帖子

如果我使用ISO-8859-1,如果我使用UTF-8和SQL数据上的奇怪字符,HTML上的问号字符

我正在制作一个像拉丁语á, ã, ç和其他人一样的页面.该站点从SQL数据库中提取数据.我正在使用这个<head>:
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"/>
使用此标题,HTML重音字符很好,但SQL数据显示为çã而不是ão,如果我将charsetISO-8859-1 更改为UTF-8,则所有HTML重音字符由 (问号)显示,SQL数据显示重音很好.
除了转义所有HTML字符或SQL字符之外,有没有办法解决它?

PS:我已经尝试过了,mysql_set_charset('utf8');并SET NAMES utf8没有对我有用.

html mysql utf-8 iso-8859-1 character-encoding

7
推荐指数
1
解决办法
1万
查看次数

realloc bug - 递增数组的最后一个元素

我试图实现一个dinamically增加数组realloc.我创建数组malloc,然后调用我的add函数,这将数组大小增加1.这是代码:

#include <stdio.h>
#include <stdlib.h>

int *foo;
int quantity;

void add(int number) {
    foo = (int*) realloc(foo, sizeof(foo) + sizeof(int));
    foo[quantity] = number;
    quantity++;
}

void debugFoo() {
    for (int i = 0; i < quantity; i++) {
        printf("foo[%i] = %i\n", i, foo[i]);
    }
    printf("\n");
}

int main() {
    quantity = 3;
    foo = (int*) malloc(quantity * sizeof(int));

    foo[0] = 1;
    foo[1] = 2;
    foo[2] = 3;

    debugFoo();

    add(20);
    debugFoo();
    add(2);
    debugFoo();

    return 0; …
Run Code Online (Sandbox Code Playgroud)

c memory-management realloc

-1
推荐指数
1
解决办法
158
查看次数