首页 \ 问答 \ unicode或unicode(to unicode or not to unicode)

unicode或unicode(to unicode or not to unicode)

我从注册表中获取了一个值。 该值可能包含双字节字符。 我稍后将通过网络其传输到C#客户端进行显示。 C#是unicode。 如果将其称为非unicode,则该函数返回MBCS。

我该怎么用?

string result = string(cbData);
RegQueryValueExA(h_sub_key, "DisplayName", NULL, NULL, (LPBYTE) &result[0], &cbData)

要么

string result = string(cbData);
RegQueryValueExW(h_sub_key, L"DisplayName", NULL, NULL, (LPBYTE) &result[0], &cbData)

I'm getting a value from the registry. This value might have double byte characters in it. I will later have to transfer this across the network to a C# client to display. C# is all unicode. The function returns MBCS if you call it non-unicode.

What should I use?

string result = string(cbData);
RegQueryValueExA(h_sub_key, "DisplayName", NULL, NULL, (LPBYTE) &result[0], &cbData)

or

string result = string(cbData);
RegQueryValueExW(h_sub_key, L"DisplayName", NULL, NULL, (LPBYTE) &result[0], &cbData)

原文:https://stackoverflow.com/questions/7573200
更新时间:2022-02-10 20:02

最满意答案

与在Java中一样,您无法在界面中指定属性。 但是使用Groovy,你可以使用一个特性:

trait GroovyInterface
{
    int intProperty
    boolean boolProperty
}

然后,您可以像使用“implements GroovyInterface”的接口一样使用它。

有关特征的更多信息,请参阅http://docs.groovy-lang.org/next/html/documentation/core-traits.html


Like in Java you cannot specify properties in an interface. But with Groovy you can use a trait for that:

trait GroovyInterface
{
    int intProperty
    boolean boolProperty
}

You can then use it exactly like an interface with "implements GroovyInterface".

For more information on traits consult http://docs.groovy-lang.org/next/html/documentation/core-traits.html

相关问答

更多
  • 很难确切地看到你想要做什么,但似乎这可能是一个更合适的设计: public class Conductor { private IPlotterHelper _plotter_helper = new PlotterHelper(); private IFileWriterHelper _file_writer_helper = new FileWriterHelper(); public void Conduct() { _file_writer_hel ...
  • 编辑 我相信我得到了你想要的东西 - 到处都是包装纸,可能比它的价值更麻烦,但值得一看: // An interface which implements IDbSet and adds on the method you want public interface IExtendedDbSet : IDbSet where T : class { DbSqlQuery SqlQuery(string sql, object[] parameters); } // ...
  • 与在Java中一样,您无法在界面中指定属性。 但是使用Groovy,你可以使用一个特性: trait GroovyInterface { int intProperty boolean boolProperty } 然后,您可以像使用“implements GroovyInterface”的接口一样使用它。 有关特征的更多信息,请参阅http://docs.groovy-lang.org/next/html/documentation/core-traits.html Like in Ja ...
  • 这取决于“属性”的含义。 如果你的意思是实际的字段,那么不,他们不会。 如果你是指C#中的属性,那么是的,他们可以(因为属性访问者对于访问者方法来说都是严格语法糖)。 同样的事情(当然,在每种情况下,没有为get / set或add / remove访问器指定实现)。 更新 :由于PHP在get / set访问器的意义上没有属性,那么您的问题的答案是否定的。 接口不能携带自己的数据/状态。 It depends what you mean by "properties". If you mean actua ...
  • 因为接口定义了一个契约 。 当你说合同需要获取时,你说实施者必须提供一个获取,你不能说“你只能这样做”,所以,给定: public interface IData { string Data { get; } } 你其实在说 public interface IData { string GetData(); } 客户端总是可以这样做: public class Data : IData { public string Data { get; set; } } 因为它实际上是这 ...
  • 限制DataAccess::update()接受您的子Model违反此接口的合约。 是的,所有Model对象都是SplSubject类,但并非所有SplSubject都是Model类。 接口是一种合同,保证实现类支持接口支持的所有内容。 您的代码,如果它工作将限制DataAccess::update()方法只限于Model子类而不是更广泛的父类SplSubjects 。 您不能缩小传递给接口定义的方法的参数范围。 假设您向Model类添加了一个属性public $foo 。 如果允许,您可以在DataAcc ...
  • 变量替换在Config.groovy 。 以下是一些实际生产代码的示例: external.config.base = '/known/config/file/path' grails.config.locations = ["file:${external.config.base}/myapp-config.groovy"] sitemap.file.path = "${external.config.base}" Variable substitution works in Config.groov ...
  • 我相信编译器抱怨的是getter返回一个“Array”,但是setter采用了“TargetSystem” 这些类型必须匹配。 (不仅在界面中,而且在类中。) I believe what the compiler is complaining about is that the getter returns an "Array", but the setter takes a "TargetSystem" Those types must match. (Not only in an interface, ...
  • 你需要更具体。 有两种方法可以解释您的问题。 一个是你有一个COM 组件 (例如一些库),并且你想要以编程方式枚举它的接口/属性/方法。 通常(但不总是),COM组件带有一个类型库,其中包含有关所有这些的完整元信息 - 它嵌入到COM .exe或.dll中,或者是一个单独的.tlb文件。 在任何情况下,如果COM组件在系统中正确注册(例如使用regsvr32),则COM提供标准API以检索以ITypeLib和ITypeInfo接口为中心的类型信息。 另一种解释是您获得对特定COM 对象的引用,并且您需要枚举 ...
  • fixture.Register(() => new Downloader()); 看起来这是IDownloader的拼写错误 fixture.Register(() => new Downloader()); fixture.Register(() => new Downloader()); Looks like that is a typo for IDownloader fixture.Register

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)