ASCII to UNICODE conversion

chinaplus 2006-05-24 04:33:18
CString str="fdsfsdfsdf";
how to convert str to LPCWSTR?
...全文
131 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
折腾_苏州 2006-05-24
  • 打赏
  • 举报
回复

//Method one:
CString str=_T("TestStr");
USES_CONVERSION;
LPWSTR pwStr=new wchar_t[str.GetLength()+1];
wcscpy(pwStr,T2W((LPCTSTR)str));

// Method two:
CString str=_T("TestStr");
USES_CONVERSION;
LPWCSTR pwcStr = A2CW((LPCSTR)str);

Just Browse from Internet,Try this two methods....
chinaplus 2006-05-24
  • 打赏
  • 举报
回复
LPCWSTR cwstr=A2CW(str);
compile wrong?
fisker0303 2006-05-24
  • 打赏
  • 举报
回复
If your project is unicode version,then CString str = _T("fdsfsdfsdf"); str is the unicode string.
you can use ATL macro A2W convert this to the unicode one.
or you can use MultiByteToWideChar API.
Features Automatic mapping from Java to native functions, with simple mappings for all primitive data types Runs on most platforms which support Java Automatic conversion between C and Java strings, with customizable encoding/decoding Structure and Union arguments/return values, by reference and by value Function Pointers, (callbacks from native code to Java) as arguments and/or members of a struct Auto-generated Java proxies for native function pointers By-reference (pointer-to-type) arguments Java array and NIO Buffer arguments (primitive types and pointers) as pointer-to-buffer Nested structures and arrays Wide (wchar_t-based) strings Native long support (32- or 64-bit as appropriate) Demo applications/examples Supported on 1.4 or later JVMs, including JavaME (earlier VMs may work with stubbed NIO support) Customizable marshalling/unmarshalling (argument and return value conversions) Customizable mapping from Java method to native function name, and customizable invocation to simulate C preprocessor function macros Support for automatic Windows ASCII/UNICODE function mappings Varargs support Type-safety for native pointers VM crash protection (optional) Optimized direct mapping for high-performance applications. COM support for early and late binding. COM/Typelib java code generator. Community and Support All questions should be posted to the jna-users Google group. Issues can be submitted here on Github. When posting to the mailing list, please include the following: What OS/CPU/architecture you're using (e.g. Windows 7 64-bit) Reference to your native interface definitions (i.e. C headers), if available The JNA mapping you're trying to use VM crash logs, if any Example native usage, and your attempted Java usage It's nearly impossible to indicate proper Java usage when there's no native reference to work from. For commercial support, please contact twalljava [at] java [dot] net. Using the Library Getting Started Functional Description. Mapping between Java and Native Using Pointers and Arrays Using Structures and Unions Using By-Reference Arguments Customization of Type Mapping Callbacks/Function Pointers/Closures Dynamically Typed Languages (JRuby/Jython) Platform Library Direct Method Mapping (Optimization) Frequently Asked Questions (FAQ) Avoiding Crashes Primary Documentation (JavaDoc) The definitive JNA reference is in the JavaDoc. Developers Contributing to JNA Setting up a Windows Development Environment Setting up an Android Development Environment Setting up a RaspberryPi Development Environment Setting up a Mac Development Environment Releasing JNA Publishing to Maven Central Contributing You're encouraged to contribute to JNA. Fork the code from https://github.com/java-native-access/jna and submit pull requests. For more information on setting up a development environment see Contributing to JNA. If you are interested in paid support, feel free to say so on the jna-users mailing list. Most simple questions will be answered on the list, but more complicated work, new features or target platforms can be negotiated with any of the JNA developers (this is how several of JNA's features came into being). You may even encounter other users with the same need and be able to cost share the new development. License This library is licensed under the LGPL, version 2.1 or later, and (from version 4.0 onward) the Apache Software License, version 2.0. Commercial license arrangements are negotiable. NOTE: Oracle is not sponsoring this project, even though the package name (com.sun.jna) might imply otherwise.
我用它来修改ldf,你呢? XVI32 is a free hex-editor with the following main features: - New: Runs on systems with > 2 GB virtual memory - New: Bugfix (script command CHARCON is now working) - Simplified search for Unicode Latin (UTF-16) strings - Script commands BITNOT, BITAND, BITOR, BITXOR, BITSHL, BITSHR - Reload command - Wheel mouse support - Computing of CRC16 (standard) and CRC32 (PKZIP compatible) for complete file and selected block (only if block is currently selected) - Data inspector to view decoded numbers - Built-in script interpreter! Refer to online help for details - Easily works with huge files. Try to open a 60 MB sized text file with some other hex editor (not to speak about Wordpad), then use XVI32... - XVI32 allows to edit files up to 2 GB (enough virtual memory provided, of course) - For your convenience, XVI32 stores settings and last used search strings etc. in XVI32.INI file - Progress indication in percent for most operations - You can abort nearly all operations (reading/writing files, search, replace, print...) - Display of both text (ASCII/ANSI) and hexadecimal representation - Two synchronous cursors in text and hex area - Fully resizeable window (change number of rows and columns) - Font and font size adjustable - Overwrite or insert characters - Insert text or hex string n times - Switch byte offset (address) of first byte between 0 or 1 to examine also record structure of plain text files - Search text or hex string, e.g. find "this text" or find "0D 0A" - Search optionally with joker char, e.g. find "A.C" or "00 2E 2E 00" where "." = "2E" (user-defined) stands for any character - Fast searching algorithm (Quicksearch) for both search directions (down/up) - Count occurences of text or hex string - Replace text or hex string, e.g. replace "0D 0A" by "0A" or replace "0D 0A" by text "EOL" - Extremely fast "replace all" mode (if needed, additional memory is allocated beforehead, not at every single replacing operation) - Auto-fill feature to copy bytes from current address into input field for hex string using right arrow key - Character conversion using self-defined character table - Easy converting of text to hex string in dialogs (e.g. "abc" -> "61 62 63") - Decoding and encoding of 1, 2, 4, and 8 byte integers or 4/8 byte floats in 2 possible byte orders - Bit manipulation (view or set bits) - Open file in Read Only mode (e.g. if opened by another application or to avoid unintentional modifications) - Insert file contents into file - Write block to file - Copy, move or delete block - Clipboard support - Goto address (absolute or relative up/down) - Up to 9 named bookmarks - Enter jump width and jump up/down (useful for files with fixed record length) - Patch BORLAND PASCAL 7.0 EXE files for execution on processors > 200 MHz - Printing with preview or print to file - Easily access most recently used files - No setup programm needed, doesn't write any data to registry - And last, but not least: XVI32 is free!

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧