JAVA-----乱码的处理 乱码的解决方法总结

为什么说乱码是程序员无法避免的话题呢?这个首先要从编码机制上说起,大家都是中文和英文的编码格式不是一样,解码也是不一样的!工作遇到各种各样的乱码的解决方法总结一下。


对于Java由于默认的编码方式是 UNICODE,所以用中文也易出问题,常见的解决是
String s2 = new String(s1.getBytes(“ISO-8859-1”),”GBK”);

http://weibo.com/p/2309274260871642686694
http://weibo.com/p/2309274260871642686694?2018.07.12&jUr6=76TG
http://weibo.com/p/2309274260871684668117
http://weibo.com/p/2309274260871684668117?2018.07.12&K0qW=Y9MP
http://weibo.com/p/2309274260871768555235
http://weibo.com/p/2309274260871768555235?2018.07.12&1ugl=Ls78
http://weibo.com/p/2309274260871797877790
http://weibo.com/p/2309274260871797877790?2018.07.12&8so5=dzti
http://weibo.com/p/2309274260871810498801
http://weibo.com/p/2309274260871810498801?2018.07.12&sKe8=WdYd
http://weibo.com/p/2309274260871827276179
http://weibo.com/p/2309274260871827276179?2018.07.12&7rA7=Te46
http://weibo.com/p/2309274260871831432586
http://weibo.com/p/2309274260871831432586?2018.07.12&p9Sf=91Re
http://weibo.com/p/2309274260871839821308
http://weibo.com/p/2309274260871839821308?2018.07.12&q23O=iO52
http://weibo.com/p/2309274260871852442345
http://weibo.com/p/2309274260871852442345?2018.07.12&1478=Ln82
http://weibo.com/p/2309274260871860793086
http://weibo.com/p/2309274260871860793086?2018.07.12&Z5aY=lVTM
http://weibo.com/p/2309274260871869181778
http://weibo.com/p/2309274260871869181778?2018.07.12&4ndt=vUdb
http://weibo.com/p/2309274260871881802803
http://weibo.com/p/2309274260871881802803?2018.07.12&kcnm=Lour
http://weibo.com/p/2309274260871881764848
http://weibo.com/p/2309274260871881764848?2018.07.12&j0ln=9c2R
http://weibo.com/p/2309274260871894347892
http://weibo.com/p/2309274260871894347892?2018.07.12&z12a=qpz0
http://weibo.com/p/2309274260871902736618
http://weibo.com/p/2309274260871902736618?2018.07.12&63Vq=wg09
http://weibo.com/p/2309274260871911125310
http://weibo.com/p/2309274260871911125310?2018.07.12&et63=6izc
http://weibo.com/p/2309274260871915319666
http://weibo.com/p/2309274260871915319666?2018.07.12&BONz=xRga
http://weibo.com/p/2309274260871936329417
http://weibo.com/p/2309274260871936329417?2018.07.12&933h=CF1v
http://weibo.com/p/2309274260871944680142
http://weibo.com/p/2309274260871944680142?2018.07.12&8aP3=SP2F
http://weibo.com/p/2309274260871944718123
http://weibo.com/p/2309274260871944718123?2018.07.12&g8tM=wd24
http://weibo.com/p/2309274260871965689883
http://weibo.com/p/2309274260871965689883?2018.07.12&99b7=6inf
http://weibo.com/p/2309274260871965689941
http://weibo.com/p/2309274260871965689941?2018.07.12&Nx01=2Zvs
http://weibo.com/p/2309274260871974040642
http://weibo.com/p/2309274260871974040642?2018.07.12&C4v3=sX8h
http://weibo.com/p/2309274260871986661727
http://weibo.com/p/2309274260871986661727?2018.07.12&f1pZ=c23J
http://weibo.com/p/2309274260871999244757
http://weibo.com/p/2309274260871999244757?2018.07.12&YR38=wYQq
http://weibo.com/p/2309274260872003439119
http://weibo.com/p/2309274260872003439119?2018.07.12&9tMw=73A8
http://weibo.com/p/2309274260872015984180
http://weibo.com/p/2309274260872015984180?2018.07.12&JlYt=128x
http://weibo.com/p/2309274260872020216547
http://weibo.com/p/2309274260872020216547?2018.07.12&dY0y=518M
http://weibo.com/p/2309274260872028605251
http://weibo.com/p/2309274260872028605251?2018.07.12&3FnY=6286
http://weibo.com/p/2309274260872036993951
http://weibo.com/p/2309274260872036993951?2018.07.12&w624=nh53
http://weibo.com/p/2309274260872045344634
http://weibo.com/p/2309274260872045344634?2018.07.12&O66g=ybZh
http://weibo.com/p/2309274260872049577013
http://weibo.com/p/2309274260872049577013?2018.07.12&XVl6=5vhg
http://weibo.com/p/2309274260872057927710
http://weibo.com/p/2309274260872057927710?2018.07.12&ufW1=oqF9
http://weibo.com/p/2309274260872066316434
http://weibo.com/p/2309274260872066316434?2018.07.12&KyIr=10jn
http://weibo.com/p/2309274260872074743197
http://weibo.com/p/2309274260872074743197?2018.07.12&5T7i=kIIf
http://weibo.com/p/2309274260872091520601
http://weibo.com/p/2309274260872091520601?2018.07.12&TVd3=FMNj
http://weibo.com/p/2309274260872095676942
http://weibo.com/p/2309274260872095676942?2018.07.12&3GnH=I6YK
http://weibo.com/p/2309274260872108298051
http://weibo.com/p/2309274260872108298051?2018.07.12&49C3=xjUd
http://weibo.com/p/2309274260872120843020
http://weibo.com/p/2309274260872120843020?2018.07.12&O568=SGWG
http://weibo.com/p/2309274260872129231764
http://weibo.com/p/2309274260872129231764?2018.07.12&8E2Z=J81j
http://weibo.com/p/2309274260872137658523
http://weibo.com/p/2309274260872137658523?2018.07.12&W0I6=7q33
http://weibo.com/p/2309274260872150203544
http://weibo.com/p/2309274260872150203544?2018.07.12&qPQI=dL62
http://weibo.com/p/2309274260872158592230
http://weibo.com/p/2309274260872158592230?2018.07.12&ou6Y=Kz5z
http://weibo.com/p/2309274260872167019043
http://weibo.com/p/2309274260872167019043?2018.07.12&tKOQ=f9Z9
http://weibo.com/p/2309274260872179563970
http://weibo.com/p/2309274260872179563970?2018.07.12&ekz6=z86l
http://weibo.com/p/2309274260872179602075
http://weibo.com/p/2309274260872179602075?2018.07.12&6173=i1yT
http://weibo.com/p/2309274260872187952672
http://weibo.com/p/2309274260872187952672?2018.07.12&8v05=k559
http://weibo.com/p/2309274260872200573817
http://weibo.com/p/2309274260872200573817?2018.07.12&34ZF=Cdbr
http://weibo.com/p/2309274260872208924416
http://weibo.com/p/2309274260872208924416?2018.07.12&jX1b=RBTo
http://weibo.com/p/2309274260872213156845
http://weibo.com/p/2309274260872213156845?2018.07.12&54ND=EapV
http://weibo.com/p/2309274260872221545577
http://weibo.com/p/2309274260872221545577?2018.07.12&x2Wv=BCXz
http://weibo.com/p/2309274260872229934273
http://weibo.com/p/2309274260872229934273?2018.07.12&yp5k=aHN2
http://weibo.com/p/2309274260872246673570
http://weibo.com/p/2309274260872246673570?2018.07.12&V28O=RmHy
http://weibo.com/p/2309274260872255100341
http://weibo.com/p/2309274260872255100341?2018.07.12&8dFd=2H5L
http://weibo.com/p/2309274260872259256668
http://weibo.com/p/2309274260872259256668?2018.07.12&4Szm=aZ8x
http://weibo.com/p/2309274260872259256688
http://weibo.com/p/2309274260872259256688?2018.07.12&AYb6=X3Eu
http://weibo.com/p/2309274260872280228464
http://weibo.com/p/2309274260872280228464?2018.07.12&NM2T=r5f8
http://weibo.com/p/2309274260872280266589
http://weibo.com/p/2309274260872280266589?2018.07.12&MLVJ=GO1T
http://weibo.com/p/2309274260872297043951
http://weibo.com/p/2309274260872297043951?2018.07.12&8dqx=yZl0
http://weibo.com/p/2309274260872301200192
http://weibo.com/p/2309274260872301200192?2018.07.12&Aoit=wQ1O
http://weibo.com/p/2309274260872317977598
http://weibo.com/p/2309274260872317977598?2018.07.12&c5m7=OF88
http://weibo.com/p/2309274260872326404399
http://weibo.com/p/2309274260872326404399?2018.07.12&ybWm=RyYj
http://weibo.com/p/2309274260872330560634
http://weibo.com/p/2309274260872330560634?2018.07.12&60IP=T2Z3
http://weibo.com/p/2309274260872338949336
http://weibo.com/p/2309274260872338949336?2018.07.12&TC9T=gDq0
http://weibo.com/p/2309274260872347376147
http://weibo.com/p/2309274260872347376147?2018.07.12&F55k=E5C2
http://weibo.com/p/2309274260872359959201
http://weibo.com/p/2309274260872359959201?2018.07.12&n1c0=e2F7
http://weibo.com/p/2309274260872359959205
http://weibo.com/p/2309274260872359959205?2018.07.12&5WOU=fN0M
http://weibo.com/p/2309274260872368347911
http://weibo.com/p/2309274260872368347911?2018.07.12&Nnew=3uu3
http://weibo.com/p/2309274260872389281566
http://weibo.com/p/2309274260872389281566?2018.07.12&i934=4HDt
http://weibo.com/p/2309274260872401902731
http://weibo.com/p/2309274260872401902731?2018.07.12&u12P=9stJ
http://weibo.com/p/2309274260872418642038
http://weibo.com/p/2309274260872418642038?2018.07.12&Rea9=C0sE
http://weibo.com/p/2309274260872422874565
http://weibo.com/p/2309274260872422874565?2018.07.12&6r4v=H6k5
http://weibo.com/p/2309274260872443846325
http://weibo.com/p/2309274260872443846325?2018.07.12&u9Um=1ou4
http://weibo.com/p/2309274260872456391222
http://weibo.com/p/2309274260872456391222?2018.07.12&FR91=dXh9
http://weibo.com/p/2309274260872464779968
http://weibo.com/p/2309274260872464779968?2018.07.12&G9Ba=8CbZ
http://weibo.com/p/2309274260872473206851
http://weibo.com/p/2309274260872473206851?2018.07.12&MRX2=A243
http://weibo.com/p/2309274260872485751720
http://weibo.com/p/2309274260872485751720?2018.07.12&c7l1=lLsO
http://weibo.com/p/2309274260872494178627
http://weibo.com/p/2309274260872494178627?2018.07.12&Cz0I=7T95
http://weibo.com/p/2309274260872494178631
http://weibo.com/p/2309274260872494178631?2018.07.12&3cnh=NfFl
http://weibo.com/p/2309274260872502567321
http://weibo.com/p/2309274260872502567321?2018.07.12&9ly4=tZMP
http://weibo.com/p/2309274260872527695260
http://weibo.com/p/2309274260872527695260?2018.07.12&115W=jbV0
http://weibo.com/p/2309274260872531927795
http://weibo.com/p/2309274260872531927795?2018.07.12&6K7E=vRD1
http://weibo.com/p/2309274260872544510873
http://weibo.com/p/2309274260872544510873?2018.07.12&CQMt=mH09
http://weibo.com/p/2309274260872561250078
http://weibo.com/p/2309274260872561250078?2018.07.12&3Fu2=be1o
http://weibo.com/p/2309274260872569676927
http://weibo.com/p/2309274260872569676927?2018.07.12&maL8=aGq3
http://weibo.com/p/2309274260872578065613
http://weibo.com/p/2309274260872578065613?2018.07.12&hhO7=iDAF
http://weibo.com/p/2309274260872590610488
http://weibo.com/p/2309274260872590610488?2018.07.12&kyd0=5DQ8
http://weibo.com/p/2309274260872599037409
http://weibo.com/p/2309274260872599037409?2018.07.12&wDlm=320L
http://weibo.com/p/2309274260872607426089
http://weibo.com/p/2309274260872607426089?2018.07.12&cFA0=o6h5
http://weibo.com/p/2309274260872615814871
http://weibo.com/p/2309274260872615814871?2018.07.12&ue3d=z3nz
http://weibo.com/p/2309274260872619970986
http://weibo.com/p/2309274260872619970986?2018.07.12&751e=aISF
http://weibo.com/p/2309274260872628397915
http://weibo.com/p/2309274260872628397915?2018.07.12&4wkW=a4vl
http://weibo.com/p/2309274260872636786653
http://weibo.com/p/2309274260872636786653?2018.07.12&eMc5=75Rd
http://weibo.com/p/2309274260872645175349
http://weibo.com/p/2309274260872645175349?2018.07.12&sDsj=28n4
http://weibo.com/p/2309274260872649369715
http://weibo.com/p/2309274260872649369715?2018.07.12&Zt28=34p7
http://weibo.com/p/2309274260872670303276
http://weibo.com/p/2309274260872670303276?2018.07.12&GG1D=maK3
http://weibo.com/p/2309274260872678691980
http://weibo.com/p/2309274260872678691980?2018.07.12&528h=d06I
http://weibo.com/p/2309274260872682886306
http://weibo.com/p/2309274260872682886306?2018.07.12&yii3=I8X7
http://weibo.com/p/2309274260872699701929
http://weibo.com/p/2309274260872699701929?2018.07.12&WvV9=CbWL
http://weibo.com/p/2309274260872703896277
http://weibo.com/p/2309274260872703896277?2018.07.12&DIUr=U03P
http://weibo.com/p/2309274260872708052430
http://weibo.com/p/2309274260872708052430?2018.07.12&pdL0=KG8r
http://weibo.com/p/2309274260872737451091
http://weibo.com/p/2309274260872737451091?2018.07.12&V9vY=54G0
http://weibo.com/p/2309274260872745801534
http://weibo.com/p/2309274260872745801534?2018.07.12&YV39=NnyT
http://weibo.com/p/2309274260872745839779
http://weibo.com/p/2309274260872745839779?2018.07.12&Yy23=WcuM
http://weibo.com/p/2309274260872766773284
http://weibo.com/p/2309274260872766773284?2018.07.12&4C56=1VK6
http://weibo.com/p/2309274260872771005919
http://weibo.com/p/2309274260872771005919?2018.07.12&e76Y=hE72
http://weibo.com/p/2309274260872787745000
http://weibo.com/p/2309274260872787745000?2018.07.12&4ZH2=Ij7T
http://weibo.com/p/2309274260872800366335
http://weibo.com/p/2309274260872800366335?2018.07.12&7EqJ=92u5
http://weibo.com/p/2309274260872808716748
http://weibo.com/p/2309274260872808716748?2018.07.12&bSFy=C53U
http://weibo.com/p/2309274260872817105460
http://weibo.com/p/2309274260872817105460?2018.07.12&241x=bkcf
http://weibo.com/p/2309274260872829688482
http://weibo.com/p/2309274260872829688482?2018.07.12&VjE8=z4Fu
http://weibo.com/p/2309274260872838115467
http://weibo.com/p/2309274260872838115467?2018.07.12&841j=89V0
http://weibo.com/p/2309274260872846504153
http://weibo.com/p/2309274260872846504153?2018.07.12&6yQf=b55T
http://weibo.com/p/2309274260872854892889
http://weibo.com/p/2309274260872854892889?2018.07.12&2tvb=eFmI
http://weibo.com/p/2309274260872867475921
http://weibo.com/p/2309274260872867475921?2018.07.12&m0kI=SPL7
http://weibo.com/p/2309274260872884253313
http://weibo.com/p/2309274260872884253313?2018.07.12&gv45=x23O
http://weibo.com/p/2309274260872922002491
http://weibo.com/p/2309274260872922002491?2018.07.12&KO6E=6sh7
http://weibo.com/p/2309274260872942935908
http://weibo.com/p/2309274260872942935908?2018.07.12&PzEl=Rot9
http://weibo.com/p/2309274260872947130302
http://weibo.com/p/2309274260872947130302?2018.07.12&ogw4=55k4
http://weibo.com/p/2309274260872963907664
http://weibo.com/p/2309274260872963907664?2018.07.12&aYpT=9NJ1
http://weibo.com/p/2309274260872972334717
http://weibo.com/p/2309274260872972334717?2018.07.12&qXqN=FXy4
http://weibo.com/p/2309274260872976490764
http://weibo.com/p/2309274260872976490764?2018.07.12&M32r=hzU7
http://weibo.com/p/2309274260872993268120
http://weibo.com/p/2309274260872993268120?2018.07.12&e0rf=7y73
http://weibo.com/p/2309274260873001695179
http://weibo.com/p/2309274260873001695179?2018.07.12&2iU7=5vvZ
http://weibo.com/p/2309274260873014278235
http://weibo.com/p/2309274260873014278235?2018.07.12&r883=dstM
http://weibo.com/p/2309274260873018472639
http://weibo.com/p/2309274260873018472639?2018.07.12&IFFx=dDQj
http://weibo.com/p/2309274260873043638707
http://weibo.com/p/2309274260873043638707?2018.07.12&rzSG=HkhE
http://weibo.com/p/2309274260873068766478
http://weibo.com/p/2309274260873068766478?2018.07.12&U16J=QwB8
http://weibo.com/p/2309274260873077155132
http://weibo.com/p/2309274260873077155132?2018.07.12&96sg=3T4W
http://weibo.com/p/2309274260873102321354
http://weibo.com/p/2309274260873102321354?2018.07.12&lw77=nf9H
http://weibo.com/p/2309274260873119098710
http://weibo.com/p/2309274260873119098710?2018.07.12&7H6b=IBa3
http://weibo.com/p/2309274260873131720203
http://weibo.com/p/2309274260873131720203?2018.07.12&h69L=4ael
http://weibo.com/p/2309274260873148497601
http://weibo.com/p/2309274260873148497601?2018.07.12&t58r=xWEJ
http://weibo.com/p/2309274260873173625458
http://weibo.com/p/2309274260873173625458?2018.07.12&o5PU=Ny19
http://weibo.com/p/2309274260873244902317
http://weibo.com/p/2309274260873244902317?2018.07.12&BavK=EIct
http://weibo.com/p/2309274260873274262787
http://weibo.com/p/2309274260873274262787?2018.07.12&P3CH=rg0c
http://weibo.com/p/2309274260873303623249
http://weibo.com/p/2309274260873303623249?2018.07.12&8Tzr=3r2G
http://weibo.com/p/2309274260873349761133
http://weibo.com/p/2309274260873349761133?2018.07.12&46SY=kSUh
http://weibo.com/p/2309274260873379121571
http://weibo.com/p/2309274260873379121571?2018.07.12&k4AE=8N4q
http://weibo.com/p/2309274260873404287685
http://weibo.com/p/2309274260873404287685?2018.07.12&tr9j=QQ0X
http://weibo.com/p/2309274260873412676391
http://weibo.com/p/2309274260873412676391?2018.07.12&E3w4=gQ3v
http://weibo.com/p/2309274260873442036837
http://weibo.com/p/2309274260873442036837?2018.07.12&2Gb4=hfWc
http://weibo.com/p/2309274260873471424304
http://weibo.com/p/2309274260873471424304?2018.07.12&EzbD=3W38
http://weibo.com/p/2309274260873601449290
http://weibo.com/p/2309274260873601449290?2018.07.12&EQwv=Mkbu
http://weibo.com/p/2309274260873630809696
http://weibo.com/p/2309274260873630809696?2018.07.12&r6G9=Dyj2
http://weibo.com/p/2309274260873660143209
http://weibo.com/p/2309274260873660143209?2018.07.12&U7Wf=Fo05
http://weibo.com/p/2309274260873685309351
http://weibo.com/p/2309274260873685309351?2018.07.12&Zs29=Y4Zf
http://weibo.com/p/2309274260873706308054
http://weibo.com/p/2309274260873706308054?2018.07.12&1h50=7ESD
http://weibo.com/p/2309274260873714696758
http://weibo.com/p/2309274260873714696758?2018.07.12&wx4c=DW7f
http://weibo.com/p/2309274260873735641609
http://weibo.com/p/2309274260873735641609?2018.07.12&nA82=FC3u
http://weibo.com/p/2309274260873744030369
http://weibo.com/p/2309274260873744030369?2018.07.12&vFcQ=zpTv
http://weibo.com/p/2309274260873748224707
http://weibo.com/p/2309274260873748224707?2018.07.12&UV1q=5sS7
http://weibo.com/p/2309274260873765029016
http://weibo.com/p/2309274260873765029016?2018.07.12&aT1j=5H8J
http://weibo.com/p/2309274260873769223390
http://weibo.com/p/2309274260873769223390?2018.07.12&rV11=YHSM
http://weibo.com/p/2309274260873781806462
http://weibo.com/p/2309274260873781806462?2018.07.12&gpS8=9E1Y
http://weibo.com/p/2309274260873798583848
http://weibo.com/p/2309274260873798583848?2018.07.12&1A05=z7x2
http://weibo.com/p/2309274260873806972590
http://weibo.com/p/2309274260873806972590?2018.07.12&ZzDk=VqRm
http://weibo.com/p/2309274260873811140027
http://weibo.com/p/2309274260873811140027?2018.07.12&Cnn8=1GkD
http://weibo.com/p/2309274260873823723135
http://weibo.com/p/2309274260873823723135?2018.07.12&ypt3=Na37
http://weibo.com/p/2309274260873832111799
http://weibo.com/p/2309274260873832111799?2018.07.12&2P9K=2Vq5
http://weibo.com/p/2309274260873840500529
http://weibo.com/p/2309274260873840500529?2018.07.12&ka5T=vjkQ
http://weibo.com/p/2309274260873853110436
http://weibo.com/p/2309274260873853110436?2018.07.12&K0z0=nc1t
http://weibo.com/p/2309274260873861472275
http://weibo.com/p/2309274260873861472275?2018.07.12&H30J=no4d
http://weibo.com/p/2309274260873869860987
http://weibo.com/p/2309274260873869860987?2018.07.12&4y7x=a4R5
http://weibo.com/p/2309274260873882444031
http://weibo.com/p/2309274260873882444031?2018.07.12&xSt9=70lZ
http://weibo.com/p/2309274260873882444047
http://weibo.com/p/2309274260873882444047?2018.07.12&ffI6=v5rj
http://weibo.com/p/2309274260873890859624
http://weibo.com/p/2309274260873890859624?2018.07.12&YLQF=F99X
http://weibo.com/p/2309274260873911804497
http://weibo.com/p/2309274260873911804497?2018.07.12&2c36=7yNr
http://weibo.com/p/2309274260873915998835
http://weibo.com/p/2309274260873915998835?2018.07.12&i5Wl=BA7h
http://weibo.com/p/2309274260873924387563
http://weibo.com/p/2309274260873924387563?2018.07.12&Lcf8=Q9h3
http://weibo.com/p/2309274260873945386154
http://weibo.com/p/2309274260873945386154?2018.07.12&Arel=TytC
http://weibo.com/p/2309274260873953774854
http://weibo.com/p/2309274260873953774854?2018.07.12&E6JW=7RgX
http://weibo.com/p/2309274260873966357920
http://weibo.com/p/2309274260873966357920?2018.07.12&6BZt=PEl9
http://weibo.com/p/2309274260873983108467
http://weibo.com/p/2309274260873983108467?2018.07.12&hS7Q=4Mx0
http://weibo.com/p/2309274260873995718380
http://weibo.com/p/2309274260873995718380?2018.07.12&tZ7g=ER2r
http://weibo.com/p/2309274260874008274573
http://weibo.com/p/2309274260874008274573?2018.07.12&WE86=iXK8
http://weibo.com/p/2309274260874020857633
http://weibo.com/p/2309274260874020857633?2018.07.12&ZOwS=VHJ4
http://weibo.com/p/2309274260874029246307
http://weibo.com/p/2309274260874029246307?2018.07.12&P294=47sg
http://weibo.com/p/2309274260874041856212
http://weibo.com/p/2309274260874041856212?2018.07.12&51Dp=R17w
http://weibo.com/p/2309274260874050218059
http://weibo.com/p/2309274260874050218059?2018.07.12&wFwE=hu3V
http://weibo.com/p/2309274260874058633604
http://weibo.com/p/2309274260874058633604?2018.07.12&Msjs=7BfM
http://weibo.com/p/2309274260874067022318
http://weibo.com/p/2309274260874067022318?2018.07.12&tq42=U8u9
http://weibo.com/p/2309274260874079578513
http://weibo.com/p/2309274260874079578513?2018.07.12&iKlf=MP2j
http://weibo.com/p/2309274260874079605362
http://weibo.com/p/2309274260874079605362?2018.07.12&VH2O=77P0
http://weibo.com/p/2309274260874087967211
http://weibo.com/p/2309274260874087967211?2018.07.12&5oa6=7jFV
http://weibo.com/p/2309274260874113133331
http://weibo.com/p/2309274260874113133331?2018.07.12&5dp1=4HC1
http://weibo.com/p/2309274260874117327707
http://weibo.com/p/2309274260874117327707?2018.07.12&DQ6h=73q7
http://weibo.com/p/2309274260874121522075
http://weibo.com/p/2309274260874121522075?2018.07.12&LfW1=Te0f
http://weibo.com/p/2309274260874142493833
http://weibo.com/p/2309274260874142493833?2018.07.12&JH2Q=bhkX
http://weibo.com/p/2309274260874146688153
http://weibo.com/p/2309274260874146688153?2018.07.12&2a0J=wYCn
http://weibo.com/p/2309274260874150909356
http://weibo.com/p/2309274260874150909356?2018.07.12&bVpO=j78D
http://weibo.com/p/2309274260874171881084
http://weibo.com/p/2309274260874171881084?2018.07.12&3gru=845s
http://weibo.com/p/2309274260874184437337
http://weibo.com/p/2309274260874184437337?2018.07.12&Y24p=353P
http://weibo.com/p/2309274260874184464136
http://weibo.com/p/2309274260874184464136?2018.07.12&Et7f=R2G8
http://weibo.com/p/2309274260874201214715
http://weibo.com/p/2309274260874201214715?2018.07.12&DLog=4iq6
http://weibo.com/p/2309274260874205409085
http://weibo.com/p/2309274260874205409085?2018.07.12&R2xw=5aD6
http://weibo.com/p/2309274260874218018922
http://weibo.com/p/2309274260874218018922?2018.07.12&126Z=BJ82
http://weibo.com/p/2309274260874226380853
http://weibo.com/p/2309274260874226380853?2018.07.12&x74X=6IcV
http://weibo.com/p/2309274260874234796370
http://weibo.com/p/2309274260874234796370?2018.07.12&PeCc=8BNl
http://weibo.com/p/2309274260874247379532
http://weibo.com/p/2309274260874247379532?2018.07.12&4rJp=rJHu
http://weibo.com/p/2309274260874255741443
http://weibo.com/p/2309274260874255741443?2018.07.12&5a8D=dOAF
http://weibo.com/p/2309274260874259935819
http://weibo.com/p/2309274260874259935819?2018.07.12&P285=Oa29
http://weibo.com/p/2309274260874264130153
http://weibo.com/p/2309274260874264130153?2018.07.12&y9Fh=qS19
http://weibo.com/p/2309274260874276713233
http://weibo.com/p/2309274260874276713233?2018.07.12&kfDm=k16q
http://weibo.com/p/2309274260874285101905
http://weibo.com/p/2309274260874285101905?2018.07.12&IvNw=PnG0
http://weibo.com/p/2309274260874289323042
http://weibo.com/p/2309274260874289323042?2018.07.12&J41Z=95DD
http://weibo.com/p/2309274260874306073709
http://weibo.com/p/2309274260874306073709?2018.07.12&dYhD=9yi0
http://weibo.com/p/2309274260874310294842
http://weibo.com/p/2309274260874310294842?2018.07.12&sW51=6ZrN
http://weibo.com/p/2309274260874339628559
http://weibo.com/p/2309274260874339628559?2018.07.12&Jk77=80dF
http://weibo.com/p/2309274260874339655308
http://weibo.com/p/2309274260874339655308?2018.07.12&IJXR=Nn5c
http://weibo.com/p/2309274260874360600345
http://weibo.com/p/2309274260874360600345?2018.07.12&L1XG=yR8i
http://weibo.com/p/2309274260874373210168
http://weibo.com/p/2309274260874373210168?2018.07.12&RzF6=c1Ms
http://weibo.com/p/2309274260874381598888
http://weibo.com/p/2309274260874381598888?2018.07.12&L542=oevv
http://weibo.com/p/2309274260874389987582
http://weibo.com/p/2309274260874389987582?2018.07.12&4vA3=9Hhd
http://weibo.com/p/2309274260874402543895
http://weibo.com/p/2309274260874402543895?2018.07.12&jjAJ=djmU
http://weibo.com/p/2309274260874410932585
http://weibo.com/p/2309274260874410932585?2018.07.12&BIAO=464H
http://weibo.com/p/2309274260874410959344
http://weibo.com/p/2309274260874410959344?2018.07.12&21Or=1uIL
http://weibo.com/p/2309274260874419321293
http://weibo.com/p/2309274260874419321293?2018.07.12&Pum6=66fM
http://weibo.com/p/2309274260874440293069
http://weibo.com/p/2309274260874440293069?2018.07.12&pY5d=CyZh
http://weibo.com/p/2309274260874444514158
http://weibo.com/p/2309274260874444514158?2018.07.12&HC0N=1J46
http://weibo.com/p/2309274260874452902868
http://weibo.com/p/2309274260874452902868?2018.07.12&Efwa=q55e
http://weibo.com/p/2309274260874473874598
http://weibo.com/p/2309274260874473874598?2018.07.12&JYQH=hJn5
http://weibo.com/p/2309274260874473874624
http://weibo.com/p/2309274260874473874624?2018.07.12&bkxR=w4iy
http://weibo.com/p/2309274260874482236577
http://weibo.com/p/2309274260874482236577?2018.07.12&iHq8=Q7i8
http://weibo.com/p/2309274260874494819669
http://weibo.com/p/2309274260874494819669?2018.07.12&7Y3r=j240
http://weibo.com/p/2309274260874503235076
http://weibo.com/p/2309274260874503235076?2018.07.12&1ee9=h3if
http://weibo.com/p/2309274260874511623826
http://weibo.com/p/2309274260874511623826?2018.07.12&9PtK=zQBz
http://weibo.com/p/2309274260874524180173
http://weibo.com/p/2309274260874524180173?2018.07.12&aUYt=2k0A
http://weibo.com/p/2309274260874532595522
http://weibo.com/p/2309274260874532595522?2018.07.12&5cSw=21S4
http://weibo.com/p/2309274260874532595538
http://weibo.com/p/2309274260874532595538?2018.07.12&w9ZO=qtDg
http://weibo.com/p/2309274260874553540693
http://weibo.com/p/2309274260874553540693?2018.07.12&b66h=6x3q
http://weibo.com/p/2309274260874553540689
http://weibo.com/p/2309274260874553540689?2018.07.12&8dZu=6z26
http://weibo.com/p/2309274260874566150374
http://weibo.com/p/2309274260874566150374?2018.07.12&DRZv=6207
http://weibo.com/p/2309274260874574512467
http://weibo.com/p/2309274260874574512467?2018.07.12&TAGg=5O65
http://weibo.com/p/2309274260874582927800
http://weibo.com/p/2309274260874582927800?2018.07.12&Guvf=ht2e
http://weibo.com/p/2309274260874591316550
http://weibo.com/p/2309274260874591316550?2018.07.12&Z8Hz=20eu
http://weibo.com/p/2309274260874603872973
http://weibo.com/p/2309274260874603872973?2018.07.12&m6Ug=S9M3
http://weibo.com/p/2309274260874616456033
http://weibo.com/p/2309274260874616456033?2018.07.12&W5t3=sa8K
http://weibo.com/p/2309274260874624871380
http://weibo.com/p/2309274260874624871380?2018.07.12&7sqW=j2DJ
http://weibo.com/p/2309274260874633233461
http://weibo.com/p/2309274260874633233461?2018.07.12&wQ8I=1Kdx
http://weibo.com/p/2309274260874645816513
http://weibo.com/p/2309274260874645816513?2018.07.12&tZIi=VM2g
http://weibo.com/p/2309274260874654231820
http://weibo.com/p/2309274260874654231820?2018.07.12&MRgO=SS8e
http://weibo.com/p/2309274260874666814916
http://weibo.com/p/2309274260874666814916?2018.07.12&l9Ue=V42r
http://weibo.com/p/2309274260874675203592
http://weibo.com/p/2309274260874675203592?2018.07.12&aGZz=ydpL
http://weibo.com/p/2309274260874687786650
http://weibo.com/p/2309274260874687786650?2018.07.12&j0D5=3o3z
http://weibo.com/p/2309274260874696175366
http://weibo.com/p/2309274260874696175366?2018.07.12&LNO5=h9S6
http://weibo.com/p/2309274260874696148783
http://weibo.com/p/2309274260874696148783?2018.07.12&VwjS=21Fp
http://weibo.com/p/2309274260874704537473
http://weibo.com/p/2309274260874704537473?2018.07.12&FLfT=6Xxl
http://weibo.com/p/2309274260874717120543
http://weibo.com/p/2309274260874717120543?2018.07.12&4e8i=94wb
http://weibo.com/p/2309274260874725509239
http://weibo.com/p/2309274260874725509239?2018.07.12&3dZ3=EJDQ
http://weibo.com/p/2309274260874729730178
http://weibo.com/p/2309274260874729730178?2018.07.12&zOS4=BV0w
http://weibo.com/p/2309274260874746480985
http://weibo.com/p/2309274260874746480985?2018.07.12&BNlV=ui6D
http://weibo.com/p/2309274260874746507572
http://weibo.com/p/2309274260874746507572?2018.07.12&9kn4=t3ZU
http://weibo.com/p/2309274260874759064033
http://weibo.com/p/2309274260874759064033?2018.07.12&RkyP=7zrH
http://weibo.com/p/2309274260874767479338
http://weibo.com/p/2309274260874767479338?2018.07.12&bNIG=59O4
http://weibo.com/p/2309274260874775868008
http://weibo.com/p/2309274260874775868008?2018.07.12&Y4Qj=1u6i
http://weibo.com/p/2309274260874780062358
http://weibo.com/p/2309274260874780062358?2018.07.12&QyBG=YWdA
http://weibo.com/p/2309274260874796813243
http://weibo.com/p/2309274260874796813243?2018.07.12&6dwe=LA61
http://weibo.com/p/2309274260874809422836
http://weibo.com/p/2309274260874809422836?2018.07.12&mE7p=9gkR
http://weibo.com/p/2309274260874809396343
http://weibo.com/p/2309274260874809396343?2018.07.12&HTB5=HKcV
http://weibo.com/p/2309274260874830394612
http://weibo.com/p/2309274260874830394612?2018.07.12&BcZ7=8n8h
http://weibo.com/p/2309274260874830394648
http://weibo.com/p/2309274260874830394648?2018.07.12&aRsA=57LF
http://weibo.com/p/2309274260874842977692
http://weibo.com/p/2309274260874842977692?2018.07.12&Rune=QKyY
http://weibo.com/p/2309274260874851339873
http://weibo.com/p/2309274260874851339873?2018.07.12&1G7N=H5so
http://weibo.com/p/2309274260874863922917
http://weibo.com/p/2309274260874863922917?2018.07.12&E5rb=81Uf
http://weibo.com/p/2309274260874872311611
http://weibo.com/p/2309274260874872311611?2018.07.12&5068=5C0Q
http://weibo.com/p/2309274260874880700331
http://weibo.com/p/2309274260874880700331?2018.07.12&x3T8=QwLW
http://weibo.com/p/2309274260874880700337
http://weibo.com/p/2309274260874880700337?2018.07.12&WXsD=Y7B1
http://weibo.com/p/2309274260874893309904
http://weibo.com/p/2309274260874893309904?2018.07.12&I5oO=Vz4X
http://weibo.com/p/2309274260874910060775
http://weibo.com/p/2309274260874910060775?2018.07.12&Z5M0=b83v
http://weibo.com/p/2309274260874914255159
http://weibo.com/p/2309274260874914255159?2018.07.12&cw1Z=kojr
http://weibo.com/p/2309274260874922670350
http://weibo.com/p/2309274260874922670350?2018.07.12&adJp=9ITf
http://weibo.com/p/2309274260874943615625
http://weibo.com/p/2309274260874943615625?2018.07.12&7H2q=2605
http://weibo.com/p/2309274260874943615659
http://weibo.com/p/2309274260874943615659?2018.07.12&SC26=1nGX
http://weibo.com/p/2309274260874952004343
http://weibo.com/p/2309274260874952004343?2018.07.12&8A9Y=f0k9
http://weibo.com/p/2309274260874977170431
http://weibo.com/p/2309274260874977170431?2018.07.12&26vy=SiOt
http://weibo.com/p/2309274260874981391254
http://weibo.com/p/2309274260874981391254?2018.07.12&kUG3=7K8w
http://weibo.com/p/2309274260874985559153
http://weibo.com/p/2309274260874985559153?2018.07.12&O608=mb7J
http://weibo.com/p/2309274260875006530983
http://weibo.com/p/2309274260875006530983?2018.07.12&BZ50=OQU5
http://weibo.com/p/2309274260875014946208
http://weibo.com/p/2309274260875014946208?2018.07.12&wC4b=Pp7I
http://weibo.com/p/2309274260875027529262
http://weibo.com/p/2309274260875027529262?2018.07.12&3aWb=raJo
http://weibo.com/p/2309274260875044306662
http://weibo.com/p/2309274260875044306662?2018.07.12&89kO=ctii
http://weibo.com/p/2309274260875056863283
http://weibo.com/p/2309274260875056863283?2018.07.12&oW09=9gmR
http://weibo.com/p/2309274260875086250134
http://weibo.com/p/2309274260875086250134?2018.07.12&M5i2=D4b3


1、utf8解决JSP中文乱码问题 
一般说来在每个页面的开始处,加入:


<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>


<%
 request.setCharacterEncoding("UTF-8");
%>


charset=UTF-8  的作用是指定JSP向客户端输出的编码方式为“UTF-8”


pageEncoding="UTF-8"  为了让JSP引擎能正确地解码含有中文字符的JSP页面,这在LINUX中很有效


 request.setCharacterEncoding("UTF-8"); 是对请求进行了中文编码


有时,这样仍不能解决问题,还需要这样处理一下:


String msg = request.getParameter("message");
 String str=new String(msg.getBytes("ISO-8859-1"),"UTF-8");
 out.println(st);


2、Tomcat 5.5 中文乱码


)只要把%TOMCAT安装目录%/   webapps\servlets-examples\WEB-INF\classes\filters\SetCharacterEncodingFilter.class文件拷到你的webapp目录/filters下,如果没有filters目录,就创建一个。   
  2)在你的web.xml里加入如下几行:   <filter>   
  <filter-name>Set   Character   Encoding</filter-name>   
  <filter-class>filters.SetCharacterEncodingFilter</filter-class>   
  <init-param>   
  <param-name>encoding</param-name>   
  <param-value>GBK</param-value>   
  </init-param>   
  </filter>   
      <filter-mapping>   
  <filter-name>Set   Character   Encoding</filter-name>   
  <url-pattern>/*</url-pattern>   
  </filter-mapping>   
    
    
    
  3)完成.   
  2   get方式的解决办法   
  1)   打开tomcat的server.xml文件,找到区块,加入如下一行:   
  URIEncoding=”GBK”   
  完整的应如下:   
  <Connector     
  port="80"   maxThreads="150"   minSpareThreads="25"   maxSpareThreads="75"   
  enableLookups="false"   redirectPort="8443"   acceptCount="100"   
  debug="0"   connectionTimeout="20000"     
  disableUploadTimeout="true"     
  URIEncoding="GBK"   
  />      
    
  2)重启tomcat,一切OK。


3、xmlHttpRequest中文问题


页面jsp用的GBK编码




代码
<%@ page contentType="text/html; charset=GBK"%> 




javascript部分


代码
function addFracasReport() {   
    var url="controler?actionId=0_06_03_01&actionFlag=0010";   
    var urlmsg="&reportId="+fracasReport1.textReportId.value;  //故障报告表编号   
           
    var xmlHttp=Common.createXMLHttpRequest();   
    xmlHttp.onreadystatechange = Common.getReadyStateHandler(xmlHttp, eval("turnAnalyPage"));   
    xmlHttp.open("POST",url,true);   
    xmlHttp.setRequestHeader( " Content-Type " , " application/x-www-form-urlencoded);   
    xmlHttp.send(urlmsg);   
       





后台java中获得的reportId是乱码,不知道该怎么转,主要是不知道xmlHttp.send(urlmsg);以后是什么编码?在后面用java来转,试了几种,都没有成功,其中有:




代码
public static String UTF_8ToGBK(String str) {   
        try {   
            return new String(str.getBytes("UTF-8"), "GBK");   
        } catch (Exception ex) {   
            return null;   
        }   
    }   
       
    public static String UTF8ToGBK(String str) {   
        try {   
            return new String(str.getBytes("UTF-16BE"), "GBK");   
        } catch (Exception ex) {   
            return null;   
        }   
    }   
       
    public static String GBK(String str) {   
        try {   
            return new String(str.getBytes("GBK"),"GBK");   
        } catch (Exception ex) {   
            return null;   
        }   
    }   
         public static String getStr(String str) {   
        try {   
            String temp_p = str;   
            String temp = new String(temp_p.getBytes("ISO8859_1"), "GBK");   
            temp = sqlStrchop(temp);   
            return temp;   
        } catch (Exception e) {   
            return null;   
        }   
    } 


4、JDBC ODBC Bridge的Bug及其解决方法


在编写一数据库管理程序时,发现JDBC-ODBC Bridge存在不易发现的Bug。在向数据表插入数据时,如果为英文字符,存储内容完全正确,如果存入中文字符,部分数据库只能存储前七八个中文字符,其他内容被截去,导致存储内容的不完整(有些数据库不存在这个问题,如Sybase SQL Anywhere 5.0。JDBC-ODBC Bridge还存在无法建表的Bug)。


  对于广大需要存储中文信息的Java程序员来说,这可是一个不好的消息。要么改用其他语言编程,要么选择其他价格昂贵的数据库产品。“一次编写,到处运行”的目标,也大打折扣。能不能采用变通的方法,将中文信息进行处理后再存储来解决这个问题呢?答案是肯定的。


  解决问题的具体思路、方法 
  Java采用Unicode码编码方式,中英文字符均采用16bit存储。既然存储英文信息是正确的,根据一定规则,将中文信息转换成英文信息后存储,自然不会出现截尾现象。读取信息时再进行逆向操作,将英文信息还原成中文信息即可。由GB2312编码规则可知,汉字一般为二个高位为1的ASCII码,在转换时将一个汉字的二个高位1去掉,还原时再将二个高位1加上。为了处理含有英文字符的中文字串,对英文字符则需要加上一个Byte 0标记。以下提供的两个公用静态方法,可加入任何一个类中使用。


  将中英文字串转换成纯英文字串 
  public static String toTureAsciiStr(String str){


  StringBuffer sb = new StringBuffer();


  byte[] bt = str.getBytes();


  for(int i =0 ;i〈bt.length;i++){


  if(bt[i]〈0){


  //是汉字去高位1


  sb.append((char)(bt[i]&&0x7f));


   }else{//是英文字符 补0作记录


  sb.append((char)0);


  sb.append((char)bt[i]);


   }


   }


  return sb.toString();


  }


  将经转换的字串还原 
  public static String unToTrueAsciiStr(String str){


   byte[] bt = str.getBytes();


   int i,l=0,length = bt.length,j=0;


   for(i = 0;i〈length;i++){


   if(bt[i] == 0){


   l++;


   }


   }


   byte []bt2 = new byte[length-l];


   for(i =0 ;i〈length;i++){


   if(bt[i] == 0){


   i++;


   bt2[j] = bt[i];


   }else{


   bt2[j] = (byte)(bt[i]|0x80);


   }


   j++;


   }


  String tt = new String(bt2);


  return tt;


  }


  上例在实际编程中效果很好,只是存储的中文信息需要经过同样处理,才能被其他系统使用。而且如果中文字串出现英文字符,实际上增加了额外的存储空间。


5、Solaris下Servlet编程的中文问题及解决办法 
在使用Java开发Internet上的一个应用系统时,发现在Windows下调试完全正常的Servlet,上传到Solaris 服务器上,运行却出现故障——返回的网页不能显示中文,应为中文的信息全为乱码;用中文信息做关键字,不能正确检索数据库。后来采用加入检查代码等方法探知故障原因如下:


  显示乱码主要是因为通过类 HttpServletResponse提供的方法setContentType 无法改变返回给客户的数据的编码方式,正确的编码方式应为GB2312或者GBK,而事实上为缺省的ISO8859-1。无法检索中文信息则是因为,客户提交的中文信息经浏览器编码到达服务器后,Servlet无法将其正确解码。


  举例说明显示乱码解决方法 
  Servlet 一般通常做法如下:


  public class ZldTestServlet extends HttpServlet {


  public void doGet (HttpServletRequest request,HttpServletResponse response)throws ServletException, IOException{


  //在使用 Writer向浏览器返回数据前,设置 content-type header ,在这里设置相应的字符集gb2312


  response.setContentType("text/html;charset=gb2312");


  PrintWriter out = response.getWriter(); //*


  // 正式返回数据


  out.println("〈html〉〈head〉〈title〉Servlet test〈/title〉〈/head〉" );


  out.println("这是一个测试页!");


  out.println("〈/body〉〈/html〉");


  out.close();


  }


   ...


  }


  解决页面显示乱码问题,需将*处代码换成如下内容:


  PrintWriter out = new PrintWriter(new OutputStreamWriter(response.getOutputStream(),"gb2312"));


  Solaris中文信息检索问题的解决 
  浏览器利用表单向服务器提交信息时,一般采用x-www-form-urlencoded 的MIME格式对数据进行编码。如果使用get方法,参数名称和参数值经编码后附加在URL后,在Java中称作查询串(query string)。


  在Servlet程序中,如果采用ServletRequest的方法getParameter取得参数值,在Solaris环境下,对汉字却不能正确解码。因而无法正确检索数据库。


  在Java 1.2的包——java.net中提供了URLEncode和URLDecode类。类URLEncode提供了按x-www-form-urlencoded格式对给定串进行转换的方法。类URLEncode则提供了逆方法。


6、Common Mail乱码问题
common mail是一个小而方便的mail包,他实现了对Java Mail的封装,使用起来十分的方便,但是我在使用他的时候发现,使用纯文本的内容发送,结果是乱码,代码如下:
public class TestCommonMail {
public static void main(String[] args) throws EmailException, MessagingException {
SimpleEmail email = new SimpleEmail();
email.setCharset("GB2312");
email.setHostName("smtp.163.com");
email.setSubject("test");
email.addTo("test@163.com");
email.setFrom("test@163.com");
email.setMsg("我的测试");
email.setAuthentication("test", "test");
email.send();
}
}


分析了一下commons mail的源码找到了原因。源码如下:
public class SimpleEmail extends Email
{
public Email setMsg(String msg) throws EmailException, MessagingException
{
if (EmailUtils.isEmpty(msg))
{
throw new EmailException("Invalid message supplied");
}


setContent(msg, TEXT_PLAIN);
return this;
}
}


Email代码片段
public void setContent(Object aObject, String aContentType)
{
this.content = aObject;
if (EmailUtils.isEmpty(aContentType))
{
this.contentType = null;
}
else
{
// set the content type
this.contentType = aContentType;


// set the charset if the input was properly formed
String strMarker = "; charset=";
int charsetPos = aContentType.toLowerCase().indexOf(strMarker);
if (charsetPos != -1)
{
// find the next space (after the marker)
charsetPos += strMarker.length();
int intCharsetEnd =
aContentType.toLowerCase().indexOf(" ", charsetPos);


if (intCharsetEnd != -1)
{
this.charset =
aContentType.substring(charsetPos, intCharsetEnd);
}
else
{
this.charset = aContentType.substring(charsetPos);
}
}
}
}


email.send();的send方法将调用
public void buildMimeMessage() throws EmailException
{
try
{
this.getMailSession();
this.message = new MimeMessage(this.session);


if (EmailUtils.isNotEmpty(this.subject))
{
if (EmailUtils.isNotEmpty(this.charset))
{
this.message.setSubject(this.subject, this.charset);
}
else
{
this.message.setSubject(this.subject);
}
}


// ========================================================
// Start of replacement code
if (this.content != null)
{
this.message.setContent(this.content, this.contentType);
}
// end of replacement code
// ========================================================
else if (this.emailBody != null)
{
this.message.setContent(this.emailBody);
}
else
{
this.message.setContent("", Email.TEXT_PLAIN);
}


if (this.fromAddress != null)
{
this.message.setFrom(this.fromAddress);
}
else
{
throw new EmailException("Sender address required");
}


if (this.toList.size() + this.ccList.size() + this.bccList.size() == 0)
{
throw new EmailException(
"At least one receiver address required");
}


if (this.toList.size() > 0)
{
this.message.setRecipients(
Message.RecipientType.TO,
this.toInternetAddressArray(this.toList));
}


if (this.ccList.size() > 0)
{
this.message.setRecipients(
Message.RecipientType.CC,
this.toInternetAddressArray(this.ccList));
}


if (this.bccList.size() > 0)
{
this.message.setRecipients(
Message.RecipientType.BCC,
this.toInternetAddressArray(this.bccList));
}


if (this.replyList.size() > 0)
{
this.message.setReplyTo(
this.toInternetAddressArray(this.replyList));
}


if (this.headers.size() > 0)
{
Iterator iterHeaderKeys = this.headers.keySet().iterator();
while (iterHeaderKeys.hasNext())
{
String name = (String) iterHeaderKeys.next();
String value = (String) headers.get(name);
this.message.addHeader(name, value);
}
}


if (this.message.getSentDate() == null)
{
this.message.setSentDate(getSentDate());
}


if (this.popBeforeSmtp)
{
Store store = session.getStore("pop3");
store.connect(this.popHost, this.popUsername, this.popPassword);
}
}
catch (MessagingException me)
{
throw new EmailException(me);
}
}
由代码可以知道纯文本方式最终调用了Java Mail的
message.setContent(this.content, this.contentType);
content是内容
contentType是类型,如text/plain,
(我们可以试试直接用Java mail发邮件,设置文本内容不使用setText方法,也使用setContent("测试", "text/plain")方式,你可以看到内容也是乱码)
关键就在于text/plain,我们改成text/plain;charset=gb2312,ok乱码解决了。在commons mail我们看SimpleEmail 类中setMsg方法调用的就是 setContent(msg, TEXT_PLAIN);我们只需要将Email类中的常量TEXT_PLAIN修改一下加入 charset=你的字符集 ,重新打包jar,这样就可以了


7、toad的字符集的设置与oracle的安装
oracle数据库服务器的安装一般是中文字符集,有时安装在不同的平台下,设置为ISO编码,toad是oracle开发的最好工具,不是我说的,可是中文环境下安装的toad,打开英文字符的oracle时,中文全是乱码。必须进行设置


环境变量---〉系统变量

  NLS_lANG=SIMPLIFIED CHINESE_CHINA.ZHS16GBK
  或
  NLS_lANG=AMERICAN_AMERICA.WE8ISO8859P1


AMERICAN_AMERICA.WE8MSWIN1252
 
 或者


 打开注册表,点击HKEY_LOCAL_MATHINE
再点击Software,再点击ORACLE
在点击HOME(ORACLE所在目录)
在注册表的右半面有NLS_LANG,
双击它,将你想要的覆盖掉原来的就可以了
最好记下旧的,以便可以改回来。




connect sys/chang_on_install
update props$
set value$='ZHS16CGB231280'
where name='NLS_CHARACTERSET';
commit;
 这样就OK了


 
8、如何解決GWT(google web toolkit)中文的問題
GWT 中文乱码解决方法


1.把你要显示的中文“测试字符串”输入到一个文件,如:1.txt 
2.进入命令行,进入1.txt所在的目录,敲入以下命令:native2ascii.exe 1.txt 2.txt 回车。这样就生成了另外一个文件2.txt。 
3.2.txt的内容如下:\u6d4b\u8bd5\u5b57\u7b26\u4e32 
4.然后用上面的编码,在gwt中使用,就可以了.


9、xmlHttp得到的网页怎么是乱码? 
(1)在服务器端使用WebRequest而不是xmlHttp
(2) 将


StreamReader sr = new StreamReader(stream);




对于简体中文改成:


StreamReader sr = new StreamReader(stream , Encoding.Default );
对于utf-8改成:




StreamReader sr = new StreamReader(stream , Encoding.UTF8 );
当然,Encoding枚举还有很多其他的成员,对于不同的编码content-type可以有选择的应用


(3)后来我发现无论是content-type是gb2312还是utf-8,用




StreamReader sr = new StreamReader(stream , Encoding.Default );


都可以返回正常的汉字,所以统一的改成Encoding.Default


 




--------------------------------------------------------------------------------


最后,在服务器端从一个url获得网页的源代码的代码如下:


 


/// <summary>
/// post一个指定的url,获得网页的源代码(用WebRequest实现)
/// </summary>
/// <param name="url"></param>
/// <returns>
/// 如果请求失败,返回null
/// 如果请求成功,返回网页的源代码
/// </returns>
public static string GetContentFromUrl2( string url )
{
    //变量定义
    string respstr;


    WebRequest myWebRequest=WebRequest.Create(url);
    //            myWebRequest.PreAuthenticate=true;
    //            NetworkCredential networkCredential=new NetworkCredential( username , password , domain );
    //            myWebRequest.Credentials=networkCredential;


    // Assign the response object of 'WebRequest' to a 'WebResponse' variable.
    WebResponse myWebResponse=myWebRequest.GetResponse();
    System.IO.Stream stream = myWebResponse.GetResponseStream();
    StreamReader sr = new StreamReader(stream , Encoding.Default );
    //以字符串形式读取数据流
    respstr = sr.ReadToEnd();
    sr.Close(); 
    
    return respstr;
        
}


10、解决weblogic/webshpere中文问题: 
在web.xml文件中需要配置中文环境。r如下: 
<context-param> 
  <param-name>weblogic.httpd.inputCharset./*</param-name> 
  <param-value>GB2312</param-value> 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值