⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 utf-8, unicode, gb2312格式串转换之-c语言版 - 平凡中的不平凡 - 博客园.htm

📁 最为全面的c++内存模型探秘。不管是初学者还是老手
💻 HTM
📖 第 1 页 / 共 5 页
字号:
width=11 align=top><SPAN class=cnblogs_code_Collapse 
id=Code_Closed_Text_151722>Code</SPAN><SPAN id=Code_Open_Text_151722><BR><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><SPAN 
style="COLOR: #008000">//</SPAN><SPAN 
style="COLOR: #008000">&nbsp;不可以移植,不推荐使用</SPAN><SPAN 
style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN 
style="COLOR: #000000">&nbsp;ReinterpretTest()<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN 
style="COLOR: #0000ff">struct</SPAN><SPAN 
style="COLOR: #000000">&nbsp;dat&nbsp;{&nbsp;</SPAN><SPAN 
style="COLOR: #0000ff">short</SPAN><SPAN 
style="COLOR: #000000">&nbsp;a;&nbsp;</SPAN><SPAN 
style="COLOR: #0000ff">short</SPAN><SPAN 
style="COLOR: #000000">&nbsp;b;};<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN 
style="COLOR: #0000ff">long</SPAN><SPAN 
style="COLOR: #000000">&nbsp;value&nbsp;</SPAN><SPAN 
style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN 
style="COLOR: #800080">0x00100020</SPAN><SPAN 
style="COLOR: #000000">;<BR>&nbsp;&nbsp;&nbsp;&nbsp;dat&nbsp;</SPAN><SPAN 
style="COLOR: #000000">*</SPAN><SPAN 
style="COLOR: #000000">&nbsp;pd&nbsp;</SPAN><SPAN 
style="COLOR: #000000">=</SPAN><SPAN 
style="COLOR: #000000">&nbsp;reinterpret_cast</SPAN><SPAN 
style="COLOR: #000000">&lt;</SPAN><SPAN 
style="COLOR: #000000">dat&nbsp;</SPAN><SPAN 
style="COLOR: #000000">*&gt;</SPAN><SPAN 
style="COLOR: #000000">&nbsp;(</SPAN><SPAN 
style="COLOR: #000000">&amp;</SPAN><SPAN 
style="COLOR: #000000">value);<BR>&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;</SPAN><SPAN 
style="COLOR: #000000">&lt;&lt;</SPAN><SPAN 
style="COLOR: #000000">&nbsp;pd</SPAN><SPAN 
style="COLOR: #000000">-&gt;</SPAN><SPAN 
style="COLOR: #000000">a&nbsp;</SPAN><SPAN 
style="COLOR: #000000">&lt;&lt;</SPAN><SPAN 
style="COLOR: #000000">&nbsp;std::endl;&nbsp;</SPAN><SPAN 
style="COLOR: #008000">//</SPAN><SPAN 
style="COLOR: #008000">&nbsp;0x0020</SPAN><SPAN 
style="COLOR: #008000"><BR></SPAN><SPAN 
style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;</SPAN><SPAN 
style="COLOR: #000000">&lt;&lt;</SPAN><SPAN 
style="COLOR: #000000">&nbsp;pd</SPAN><SPAN 
style="COLOR: #000000">-&gt;</SPAN><SPAN 
style="COLOR: #000000">b&nbsp;</SPAN><SPAN 
style="COLOR: #000000">&lt;&lt;</SPAN><SPAN 
style="COLOR: #000000">&nbsp;std::endl;&nbsp;</SPAN><SPAN 
style="COLOR: #008000">//</SPAN><SPAN 
style="COLOR: #008000">&nbsp;0x0010</SPAN><SPAN 
style="COLOR: #008000"><BR></SPAN><SPAN 
style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN 
style="COLOR: #0000ff">return</SPAN><SPAN 
style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #800080">0</SPAN><SPAN 
style="COLOR: #000000">;<BR>}<BR><BR>typedef&nbsp;</SPAN><SPAN 
style="COLOR: #0000ff">void</SPAN><SPAN 
style="COLOR: #000000">&nbsp;(</SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN 
style="COLOR: #000000">Fun)();<BR><BR></SPAN><SPAN 
style="COLOR: #0000ff">int</SPAN><SPAN 
style="COLOR: #000000">&nbsp;Testing()<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;</SPAN><SPAN 
style="COLOR: #000000">&lt;&lt;</SPAN><SPAN 
style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN 
style="COLOR: #800000">Testing</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN 
style="COLOR: #000000">&nbsp;</SPAN><SPAN 
style="COLOR: #000000">&lt;&lt;</SPAN><SPAN 
style="COLOR: #000000">&nbsp;std::endl;<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN 
style="COLOR: #0000ff">return</SPAN><SPAN 
style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #800080">10</SPAN><SPAN 
style="COLOR: #000000">;<BR>}<BR><BR></SPAN><SPAN 
style="COLOR: #0000ff">void</SPAN><SPAN 
style="COLOR: #000000">&nbsp;ReinterpretTest2()<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN 
style="COLOR: #008000">//</SPAN><SPAN 
style="COLOR: #008000">Fun&nbsp;f&nbsp;=&nbsp;(Fun)Testing;<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN 
style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">f();</SPAN><SPAN 
style="COLOR: #008000"><BR></SPAN><SPAN 
style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;Fun&nbsp;f&nbsp;</SPAN><SPAN 
style="COLOR: #000000">=</SPAN><SPAN 
style="COLOR: #000000">&nbsp;reinterpret_cast</SPAN><SPAN 
style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">Fun</SPAN><SPAN 
style="COLOR: #000000">&gt;</SPAN><SPAN 
style="COLOR: #000000">(Testing);<BR>&nbsp;&nbsp;&nbsp;&nbsp;f();<BR>}</SPAN></SPAN></DIV>
<P>&nbsp;</P>
<P>三 总结</P>
<P><SPAN 
style="COLOR: #ff0000">在C++一般更推荐新加的static_cast,const_cast,dynamic_cast和reinterpret_cast转化方式;</SPAN></P>
<DIV id=MySignature>
<P>感谢,Thanks!<BR><BR>作者:<A href="http://itech.cnblogs.com/">iTech</A><BR>出处:<A 
href="http://itech.cnblogs.com/">http://itech.cnblogs.com/</A> 
<BR>转载:本文版权归作者iTech所有,转载请注明出处,不得用于商业用途!</P></DIV>
<DIV id=EntryTag>Tag标签: <A 
href="http://www.cnblogs.com/itech/tag/[Cpp对象模型]/">[Cpp对象模型]</A></DIV></DIV>
<DIV class=postDesc>posted @ 2009-03-01 19:36 <A 
href="http://www.cnblogs.com/itech/">iTech</A> 阅读(51) <A 
href="http://www.cnblogs.com/itech/archive/2009/02/25/1398230.html#Post">评论(0)</A> 
&nbsp;<A 
href="http://www.cnblogs.com/itech/admin/EditPosts.aspx?postid=1398230">编辑</A> 
<A href="http://www.cnblogs.com/itech/AddToFavorite.aspx?id=1398230">收藏</A> <A 
onclick="PutInWz();return false;" 
href="http://www.cnblogs.com/itech/archive/2009/02/25/1398230.html#">网摘</A> 
所属分类: <A href="http://www.cnblogs.com/itech/category/170009.html">C++</A> 
</DIV></DIV><IMG height=1 
src="UTF-8, Unicode, GB2312格式串转换之-C语言版 - 平凡中的不平凡 - 博客园.files/1398230.jpg" 
width=1> <!--
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
<rdf:Description
rdf:about="http://www.cnblogs.com/itech/archive/2009/03/01/1398230.html"
dc:identifier="http://www.cnblogs.com/itech/archive/2009/03/01/1398230.html"
dc:title=""
trackback:ping="http://www.cnblogs.com/itech/services/trackbacks/1398230.aspx" />
</rdf:RDF>
--></DIV><!--end: topics 文章、评论容器-->
<DIV id=AjaxHolder_UpdatePanel1>
<STYLE>TD {
	FONT-SIZE: 12px
}
.commentTextBox {
	FONT-SIZE: 13px; FONT-FAMILY: Verdana
}
A.blue:visited {
	COLOR: blue
}
A.blue:active {
	COLOR: blue
}
A.blue:link {
	COLOR: blue
}
A.blue:hover {
	COLOR: blue
}
</STYLE>
<!--Beging Temp Save-->
<STYLE>.userData {
	BEHAVIOR: url(#default#userdata)
}
</STYLE>

<DIV class=userData id=CommentsPersistDiv></DIV>
<SCRIPT type=text/javascript>
    function pageLoad() {
        Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(handleInitializeRequest);
        //Sys.WebForms.PageRequestManager.getInstance().add_endRequest(handleEndRequest);
    }

    function handleInitializeRequest(sender, args) {
        var prm = Sys.WebForms.PageRequestManager.getInstance();
        var eid = args.get_postBackElement().id;
        /*if (eid.indexOf("DeleteLink")>0) 
        {
        args.get_postBackElement().innerHTML = "<font color='red'>正在删除...</font>";         
        }    
        else */
        if (eid.indexOf("btnSubmit") > 0) {
            document.getElementById("AjaxHolder_PostComment_ltSubmitMsg").innerHTML = "正在提交...";
            document.getElementById("AjaxHolder_PostComment_btnSubmit").disabled = true;
        }
        else if (eid.indexOf("refreshList") > 0) {
            document.getElementById("AjaxHolder_PostComment_refreshList").innerHTML = "<font color='red'>正在刷新...</font>";
        }

    }

    function TempSave(ElementID) {
        try {
            CommentsPersistDiv.setAttribute("CommentContent", document.getElementById(ElementID).value);
            CommentsPersistDiv.save("CommentXMLStore");
        }
        catch (ex) {
        }

    }
    function Restore(ElementID) {
        CommentsPersistDiv.load("CommentXMLStore");
        document.getElementById(ElementID).value = CommentsPersistDiv.getAttribute("CommentContent");
    }	
			
			
</SCRIPT>
<!--Ene TempSave-->
<DIV id=divRefreshComments 
style="FONT-SIZE: 12px; MARGIN-BOTTOM: 5px; MARGIN-RIGHT: 10px; TEXT-ALIGN: right"><A 
id=AjaxHolder_PostComment_refreshList 
href="javascript:__doPostBack('AjaxHolder$PostComment$refreshList','')">刷新评论列表</A>&nbsp;&nbsp;</DIV>
<DIV class=commentform><SPAN id=AjaxHolder_PostComment_ltSubmitMsg 
style="COLOR: red"></SPAN><BR><A name=Feedback></A>
<TABLE style="WIDTH: 600px" cellSpacing=1 cellPadding=1 border=0>
  <TBODY>
  <TR>
    <TD colSpan=3>
      <DIV id=AjaxHolder_PostComment_panelADUper></DIV></TD></TR>
  <TR>
    <TD></TD>
    <TD></TD>
    <TD></TD></TR>
  <TR>
    <TD width=55>姓名 </TD>
    <TD colSpan=2><INPUT class=tb_comment_name 
      id=AjaxHolder_PostComment_tbName name=AjaxHolder$PostComment$tbName> <A 
      href="http://passport.cnblogs.com/login.aspx?ReturnUrl=http%3a%2f%2fwww.cnblogs.com%2fitech%2farchive%2f2009%2f02%2f25%2f1398230.html">[登录]</A> 
      <A 
      href="http://passport.cnblogs.com/register.aspx?ReturnUrl=http%3a%2f%2fwww.cnblogs.com%2fitech%2farchive%2f2009%2f02%2f25%2f1398230.html%23Top">[注册]</A><SPAN 
      id=AjaxHolder_PostComment_RequiredFieldValidator2 
      style="VISIBILITY: hidden; COLOR: red">请输入你的姓名</SPAN> </TD></TR>
  <TR>
    <TD>主页 </TD>
    <TD><INPUT class=commenttb id=AjaxHolder_PostComment_tbUrl 
      name=AjaxHolder$PostComment$tbUrl> </TD>
    <TD></TD></TR>
  <TR id=AjaxHolder_PostComment_trEmail>
    <TD>Email </TD>
    <TD colSpan=2><INPUT class=commenttb id=AjaxHolder_PostComment_tbEmail 
      name=AjaxHolder$PostComment$tbEmail>(仅博主可见)<SPAN 
      id=AjaxHolder_PostComment_revContactMail 
      style="VISIBILITY: hidden; COLOR: red">邮件地址无效</SPAN> </TD></TR>
  <TR>
    <TD align=left colSpan=3>
      <TABLE class=CommentForm id=AjaxHolder_PostComment_tbCaptchaImage 
      cellSpacing=0 cellPadding=0 border=0>
        <TBODY>
        <TR>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -