convert

Convert WPF (XAML) Control to XPS Document

匿名 (未验证) 提交于 2019-12-03 08:35:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Can I take an Existing WPF (XAML) Control, databind it and turn it into an XPS document that can be displayed and printed using the WPF XPS Document Viewer? If so, how? If not, how should I be doing ‘reporting’ in WPF using XPS/PDF/etc? Basically I want to take an existing WPF control, databind it to get useful data into it and then make it printable and saveable for the end user. Ideally the document creation would be done in memory and wouldn’t hit the disk unless the user specifically saved the document. Is this feasible? 回答1: Actually

Python: convert string from UTF-8 to Latin-1

匿名 (未验证) 提交于 2019-12-03 08:35:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I feel stacked here trying to change encodings with Python 2.5 I have XML response, which I encode to UTF-8: response.encode('utf-8') . That is fine, but the program which uses this info doesn't like this encoding and I have to convert it to other code page. Real example is that I use ghostscript python module to embed pdfmark data to a PDF file - end result is with wrong characters in Acrobat. I've done numerous combinations with .encode() and .decode() between 'utf-8' and 'latin-1' and it drives me crazy as I can't output correct result.

Convert hex to decimal in R

匿名 (未验证) 提交于 2019-12-03 08:33:39
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I found out that there is function called .hex.to.dec in the fBasics package. When I do .hex.to.dec(a) , it works. I have a data frame with a column samp_column consisting of such values: a373, 115c6, a373, 115c6, 176b3 When I do .hex.to.dec(samp_column) , I get this error: "Error in nchar(b) : 'nchar()' requires a character vector" When I do .hex.to.dec(as.character(samp_column)) , I get this error: "Error in rep(base.out, 1 + ceiling(log(max(number), base = base.out))) : invalid 'times' argument" What would be the best way of doing this?

How can I convert a Sql Server 2008 DateTimeOffset to a DateTime

匿名 (未验证) 提交于 2019-12-03 08:33:39
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm hoping to convert a table which has a DATETIMEOFFSET field, down to a DATETIME field BUT recalculates the time by taking notice of the offset. This, in effect, converts the value to UTC . eg. CreatedOn: 2008-12-19 17:30:09.0000000 +11:00 that will get converted to CreatedOn: 2008-12-19 06:30:09.0000000 or CreatedOn: 2008-12-19 06:30:09.0000000 + 00:00 DATETIMEOFFSET, but UTC . Cheers :) 回答1: Converting using almost any style will cause the datetime2 value to be converted to UTC. Also, conversion from datetime2 to datetimeoffset simply

Convert a Scala list to a tuple?

匿名 (未验证) 提交于 2019-12-03 08:33:39
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How can I convert a list with (say) 3 elements into a tuple of size 3? For example, let's say I have val x = List(1, 2, 3) and I want to convert this into (1, 2, 3) . How can I do this? 回答1: You can't do this in a typesafe way. Why? Because in general we can't know the length of a list until runtime. But the "length" of a tuple must be encoded in its type, and hence known at compile time. For example, (1,'a',true) has the type (Int, Char, Boolean) , which is sugar for Tuple3[Int, Char, Boolean] . The reason tuples have this restriction is

convert pymongo cursor to json

匿名 (未验证) 提交于 2019-12-03 08:33:39
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I know this is a fairly common problem. I'm writing a small Flask app and I'm trying to feed some queries back to the view. I've connected to my local MongoDB setup, and made a successful query - but I can't generate a json object with it. The most common solution I've seen is to import json_util from pymongo i.e. import json from pymongo import json_util results = connection.get_collection('papayas_papaya') results = results.find({ 'identifier': '1', }) serialized_results = [json.dumps(result, default=json_util.default, separators=(',', ':'

Convert List(of object) to List(of string)

匿名 (未验证) 提交于 2019-12-03 08:33:39
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Is there a way to convert a List(of Object) to a List(of String) in c# or vb.net without iterating through all the items? (Behind the scenes iteration is fine - I just want concise code) Update: The best way is probably just to do a new select myList.Select(function(i) i.ToString()) or myList.Select(i => i.ToString()); 回答1: Not possible without iterating to build a new list. You can wrap the list in a container that implements IList. You can use LINQ to get a lazy evaluated version of IEnumerable from an object list like this: var stringList

Cannot convert from 'method group' to 'System.Action<object>' error

匿名 (未验证) 提交于 2019-12-03 08:33:39
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have created the following function: public void DelegatedCall(Action<Object> delegatedMethod) And defined the following method public void foo1(String str) { } However, when I try to call DelegateCall with foo1 : DelegatedCall(foo1); ...I get the following compiler error: Argument 1: cannot convert from 'method group' to 'System.Action<object>' What is the reason for this error and how can I correct it? Unfortunately, casting foo1 to Action is not an option. 回答1: DelegatedCall expects a delegate that takes any object as an argument. But

Mule ESB 3.6 - Best way to convert BufferedInputStream to XML

匿名 (未验证) 提交于 2019-12-03 08:33:39
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a Mule ESB project using HTTP Connector where I want to use XPath to split/route the XML. The message payload after the HTTP Connector is a org.glassfish.grizzly.utils.BufferInputStream. What is the best way to transform this to a type where I can use a component such as a 'Splitter' or 'Expression' (using XPath) to split/route it? The 'Object to XML' doesn't seem to work and the splitter doesn't work when the payload is a String (i.e. using Object to String after HTTP). I would rather not write a custom Java transformer if there are

(Javascript) Convert Byte[] to image

匿名 (未验证) 提交于 2019-12-03 08:30:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Using Javascript, I'm doing an AJAX call to a WCF service and it is returning a byte array. How can I convert that to an image and display it on the web page? 回答1: I realize this is an old thread, but I managed to do this through an AJAX call on a web service and thought I'd share... I have an image in my page already: AJAX: $.ajax({ type: 'POST', contentType: 'application/json; charset=utf-8', dataType: 'json', timeout: 10000, url: 'Common.asmx/GetItemPreview', data: '{"id":"' + document.getElementById("AwardDropDown").value + '"}', success