Thursday, 26 December 2013

How to read keyboard symbols

How to read keyboard symbols

~tilde (sounds like til-da); be prepared to explain to computer-illiterate people saying "you know, the wave-shaped thingy"
!exclamation; commonly read as bang in case of #!/bin/sh
@at
#pound; but commonly read as shee in case of #!/bin/sh, not sure why
$dollar
%percent
^caret; not many people know this word so be prepared to say "no, not carrot; it's the character above 6, an arrow pointing up"
&ampersand
*star; some read asterisk
(opening parenthesis (some may shorten it saying paren)
)closing parenthesis
_underscore; once I heard people say underbar
+plus
-minus, hyphen; as symbol before arguments in commands, some people including me read dash, easier to say one syllable
=equals
`backtick or backquote
{opening brace
}closing brace
[opening bracket
]closing bracket
|pipe or vertical bar
\backslash; be prepared to explain to some computer-illiterate people
:colon
;semicolon
"double quote
'single quote
<less than; some may read left angle bracket
>greater than
,comma
.dot; period if in English text
?question mark
/slash or forward slash; some computer-illiterate people may be confused about / and \
space
(), [] and {}may also be called brackets in general. In that case, they specifically call [] square brackets and {} curly brackets. I never like this. Open and Closing may also be called left and right.

can't install vim to my new Ubuntu 12.04 安装不了vim

新装了一个ubuntu 12.04,缺发现安装不了VIM

Code:

sudo apt-get install vim

错误信息:

E: Package 'vim' has no installation candidate


使用以下方案解决问题:
先运行下 
Code:
sudo apt-get update
应该是更新源信息,然后再运行

Code:

sudo apt-get install vim

成功!

-------------------------------------------------------------------------------------
I could not install vim to my new ubuntu 12.04

Code:

sudo apt-get install vim

can't install vim, got the error message:

E: Package 'vim' has no installation candidate


If you have only just installed Ubuntu, you need to run the following first:
Code:
sudo apt-get update
Then try installing vim again

Code:

sudo apt-get install vim

succeed!

Tuesday, 10 September 2013

gb18030 to ufg-8 in Linux

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

int code_convert(char *from_charset,char *to_charset,char *inbuf,int inlen,char *outbuf,int outlen)
{
        iconv_t cd;
        int rc;
        char **pin = &inbuf;
        char **pout = &outbuf;

        cd = iconv_open(to_charset,from_charset);
        if (cd==0)
        {
            printf("no support\n");
                return -1;
        }
        memset(outbuf,0,outlen);
        if (iconv(cd,pin,&inlen,pout,&outlen) == -1)
        {
            printf("conv error\n");
                return -1;
        }
        iconv_close(cd);
        return 0;
}

int u2g(char *inbuf,int inlen,char *outbuf,int outlen)
{
        return code_convert("utf-8","#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <iconv.h>

int code_convert(char *from_charset,char *to_charset,char *inbuf,int inlen,char *outbuf,int outlen)
{
        iconv_t cd;
        int rc;
        char **pin = &inbuf;
        char **pout = &outbuf;

        cd = iconv_open(to_charset,from_charset);
        if (cd==0)
        {
            printf("no support\n");
                return -1;
        }
        memset(outbuf,0,outlen);
        if (iconv(cd,pin,&inlen,pout,&outlen) == -1)
        {
            printf("conv error\n");
                return -1;
        }
        iconv_close(cd);
        return 0;
}

int u2g(char *inbuf,int inlen,char *outbuf,int outlen)
{
        return code_convert("utf-8","gb18030",inbuf,inlen,outbuf,outlen);
}

int g2u(char *inbuf,size_t inlen,char *outbuf,size_t outlen)
{
        return code_convert("gb18030","utf-8",inbuf,inlen,outbuf,outlen);
}

int main()
{
 char str_in[] = "王弢";
 char str_out[6] = {'1'};
 u2g(str_in, strlen(str_in), str_out, 4);
 printf("%d\n", strlen(str_out));
 printf("%d\n", strchr(str_out, '|') - str_out);
 return 0;
}",inbuf,inlen,outbuf,outlen);
}

int g2u(char *inbuf,size_t inlen,char *outbuf,size_t outlen)
{
        return code_convert("gb18030","utf-8",inbuf,inlen,outbuf,outlen);
}

int main()
{
 char str_in[] = "王弢";
 char str_out[6] = {'1'};
 u2g(str_in, strlen(str_in), str_out, 4);
 printf("%d\n", strlen(str_out));
 printf("%d\n", strchr(str_out, '|') - str_out);
 return 0;
}