cºÍjavaÖеĶþ½øÖÆÎļþ
×î½üÐèҪдһ¶Î³ÌÐò£¬Íê³ÉÒÔÏµĹ¤×÷£¬ÓÃjava½«Êý¾ÝÒÔ¶þ½øÖƵÄÐÎʽдÈëÎļþÖУ¬È»ºóÓÃC¶Á³ö´Ë¶þ½øÖÆÎļþ¡£
¿ªÊ¼µÄʱºòûÓп¼ÂÇ»úÆ÷µÄ×Ö½ÚÐò£¬Ö±½Ó¸ã³ösegment fault.ÏëÁ˺ܾ㬲ÅÃ÷°×ÔÀ´ÊÇjavaºÍCµÄ×Ö½ÚÐòÊDz»Ò»ÑùµÄ¡£
javaÖеÄ×Ö½ÚÐòÊÇbig endianµÄ£¬ËüÊÇÓë»úÆ÷Î޹صġ£¶øcµÄ×Ö»úÐòÊÇ»úÆ÷Ïà¹ØµÄ£¬¶øµ±Ç°ÓõĻúÆ÷ÊÇx84_64½á¹¹£¬ÊÇlittle endianµÄ£¬
ËùÒÔ³ö´í¾Í²»×ãΪÆæÁË¡£
±³¾°ÖªÊ¶£º
Ö÷»ú×Ö½ÚÐò
²»Í¬µÄCPUÓв»Í¬µÄ×Ö½ÚÐòÀàÐÍ ÕâЩ×Ö½ÚÐòÊÇÖ¸ÕûÊýÔÚÄÚ´æÖб£´æµÄ˳Ðò Õâ¸ö½Ð×öÖ÷»úÐò
×î³£¼ûµÄÓÐÁ½ÖÖ
1£® Little endian£º½«µÍÐò×Ö½Ú´æ´¢ÔÚÆðʼµØÖ·
2£® Big endian£º½«¸ßÐò×Ö½Ú´æ´¢ÔÚÆðʼµØÖ·
LE little-endian
×î·ûºÏÈ˵Ä˼άµÄ×Ö½ÚÐò
µØÖ·µÍλ´æ´¢ÖµµÄµÍλ
µØÖ·¸ßλ´æ´¢ÖµµÄ¸ßλ
Ôõô½²ÊÇ×î·ûºÏÈ˵Ä˼άµÄ×Ö½ÚÐò£¬ÊÇÒòΪ´ÓÈ˵ĵÚÒ»¹Û¸ÐÀ´Ëµ
µÍλֵС£¬¾ÍÓ¦¸Ã·ÅÔÚÄÚ´æµØַСµÄµØ·½£¬Ò²¼´ÄÚ´æµØÖ·µÍλ
·´Ö®£¬¸ßλֵ¾ÍÓ¦¸Ã·ÅÔÚÄÚ´æµØÖ·´óµÄµØ·½£¬Ò²¼´ÄÚ´æµØÖ·¸ßλ
BE big-endian
×îÖ±¹ÛµÄ×Ö½ÚÐò
µØÖ·µÍλ´æ´¢ÖµµÄ¸ßλ
µØÖ·¸ßλ´æ´¢ÖµµÄµÍλ
Ϊʲô˵ֱ¹Û£¬²»Òª¿¼ÂǶÔÓ¦¹Øϵ
Ö»ÐèÒª°ÑÄÚ´æµØÖ·´Ó×óµ½ÓÒ°´ÕÕÓɵ͵½¸ßµÄ˳Ðòд³ö
°ÑÖµ°´ÕÕͨ³£µÄ¸ßλµ½µÍλµÄ˳Ðòд³ö
Á½Õ߶ÔÕÕ£¬Ò»¸ö×Ö½ÚÒ»¸ö×Ö½ÚµÄÌî³ä½øÈ¥
Àý×Ó£ºÔÚÄÚ´æÖÐË«×Ö0x01020304(DWORD)µÄ´æ´¢·½Ê½
ÄÚ´æµØÖ·
4000 4001 4002 4003
LE 04 03 02 01
BE 01 02 03 04
Àý×Ó£ºÈç¹ûÎÒÃǽ«0x1234abcdдÈëµ½ÒÔ0x0000¿ªÊ¼µÄÄÚ´æÖУ¬Ôò½á¹ûΪ
big-endian little-endian
0x0000 0x12 0xcd
0x0001 0x23 0xab
0x0002 0xab 0x34
0x0003 0xcd 0x12
x86ϵÁÐCPU¶¼ÊÇlittle-endianµÄ×Ö½ÚÐò.
ÍøÂç×Ö½ÚÐò
ÍøÂç×Ö½Ú˳ÐòÊÇTCP/IPÖй涨ºÃµÄÒ»ÖÖÊý¾Ý±íʾ¸ñʽ£¬ËüÓë¾ßÌåµÄCPUÀàÐÍ¡¢²Ù×÷ϵͳµÈÎ޹أ¬´Ó¶ø¿ÉÒÔ±£Ö¤Êý¾ÝÔÚ²»Í¬Ö÷»úÖ®¼ä´«ÊäʱÄܹ»±»ÕýÈ·½âÊÍ¡£ÍøÂç×Ö½Ú˳Ðò²ÉÓÃbig endianÅÅÐò·½Ê½¡£
ΪÁ˽øÐÐת»» bsd socketÌṩÁËת»»µÄº¯Êý ÓÐÏÂÃæËĸö
htons °Ñunsigned shortÀàÐÍ´ÓÖ÷»úÐòת»»µ½ÍøÂçÐò
htonl °Ñunsigned longÀàÐÍ´ÓÖ÷»úÐòת»»µ½ÍøÂçÐò
ntohs °Ñunsigned shortÀàÐÍ´ÓÍøÂçÐòת»»µ½Ö÷»úÐò
ntohl °Ñunsigned longÀàÐÍ´ÓÍøÂçÐòת»»µ½Ö÷»úÐò
ÔÚʹÓÃlittle endianµÄϵͳÖÐ ÕâЩº¯Êý»á°Ñ×Ö½ÚÐò½øÐÐת»»
ÔÚʹÓÃbig endianÀàÐ͵ÄϵͳÖÐ ÕâЩº¯Êý»á¶¨Òå³É¿Õºê
ͬÑù ÔÚÍøÂç³ÌÐò¿ª·¢Ê± »òÊÇ¿çƽÌ
Ïà¹ØÎĵµ£º
1¡¢²âÊÔ·½·¨ÈçÏ£º
public static String toUtf8(String str) {
return new String(str.getBytes("UTF-8"),"UTF-8"):
&nb ......
¡¾Ò»¡¿»ùÓÚ×Ö½ÚµÄÊäÈëÁ÷
ÖµµÃ×¢ÒâµÄµØ·½ÓУº
¢ÙLevel 2µÄÊäÈëÁ÷£¬´ó¶àÊý¶¼»áÖ¸Ã÷Êý¾ÝÔ´µÄÐÎʽ£ºÀýÈçByteArray£¬File£¬Piped
¢ÚLevel 3µÄÊäÈëÁ÷£¬Ôò²»»á³öÏÖ¾ßÌåµÄÊý¾ÝÔ´Ãû×Ö£¬¶øÊÇÒÔ¹¦ÄÜÈ¡´ú£ºÀýÈçBuffered£¬LineNumber
ËùÒÔ˵Level 3µÄÊäÈëÁ÷ÊǶÔLevel 2ÊäÈëÁ÷µÄ“·â×°ºÍ¹ýÂË”¡£Êµ¼ÊÉÏLevel 2µÄÊäÈëÁ÷£¬¶¼¼ ......
1.Ê×ÏÈ¿´¶®¹Ù·½Îĵµ
2.icbc.jarÕâ¸öjar°üÒ»¶¨ÒªÒªµ½£¡ÕâÊǽøÐÐbase64¼ÓÃܽâÃÜ£¬ÒÔ¼°
ʹÓù¤ÐÐÖ¤ÊéÇ©ÃûµÄÖØÒª¹¤¾ßÀà¡£
3.²ÉÈ¡´¿Java±àÂ룬Ҫȷ±£ÓöÔÖ¤Ê飬·ÅÔÚDÅ̸ùĿ¼ÏÂ(ÆäËû·¾¶Òà¿É)¡£
4.±àдJSP½Ó¿ÚÒ³Ã棬×ֶαØÐëÓ빤ÐеÄÒ»Ò»¶ÔÓ¦¡£
¶øÇÒÈçtranDataµÈ×ֶνøÐÐbase64¼ÓÃܺó»òÕßÇ©Ãûºó ±ØÐëÒÔ"“Ë«ÒýºÅÀ©ÉϲŠ......
Ã÷ÌìÓÐÒ»¸öеľÍÒµ°à¿ª¿ÎÁË£¬ÓеÄͬѧ¾ö¶¨×ª°à£¬×Ô¼ºÐÄÀïҲͦì¶ÜµÄ£¬ÓÌÔ¥²»¾ö£¡
È¥¿ÉÒÔÈÃ×Ô¼º¶Ô»ù´¡¸ü¼ÓÊìÁ·£¬±Ï¾¹ËùÓеÄ֪ʶ¶¼ÊÇж«Î÷£¬Èç¹ûÓиü¶àµÄʱ¼äÁ·Ï°£¬Ð§¹ûÒ»
¶¨¸üºÃ£¡²»È¥ÊǾõµÃÔÀí¶¼¶®µÃÁË£¬Ö»Òª¼á³ÖÉÏÍêʣϵĿγ̣¬¿ÉÒÔÔÙÈ¥ÂýÂýÁ·Ï°´úÂ룬ûÓÐ
±ØÒªÀË·Ñʱ¼ä£¿ºÃì¶Ü£¬Ã÷ÌìÕÒÕÅÀÏʦ×ÉѯÏÂ....
½ñ ......