Search Results

Search found 37183 results on 1488 pages for 'string conversion'.

Page 126/1488 | < Previous Page | 122 123 124 125 126 127 128 129 130 131 132 133  | Next Page >

  • Convert NSMutableArray to string and back

    - by Friendlydeveloper
    Hello, in my current project I'm facing the following problem: The app needs to exchange data with my server, which are stored inside a NSMutableArray on the iPhone. The array holds NSString, NSData and CGPoint values. Now, I thought the easiest way to achieve this, was to convert the array into a properly formatted string, send it to my server and store it inside some mySQL database. At this point I'd like to request my data from my server, receive the string, which represents contents of my array and then actually convert it back into a NSMutablArray. So far, I tried something like this: NSString *myArrayString = [myArray description]; Now I send this string to my server and store it inside my mySQL database. That part works really well. However, when I receive the string from my server, I have trouble converting it back into a NSMutableArray. Is there a method, which can easily convert array description back into an array? Unfortunately I couldn't find anything on that so far. Maybe my way of "serializing" the array is wrong right from the start and there is a smarter way to do this. Any help appreciated. Thanks in advance.

    Read the article

  • how convert DataTable to List<String> in C#

    - by Jitendra Jadav
    Hello Everyone .. I am using C# Linq now I am converting DataTable to List and I am getting stuck... give me right direction thanks.. private void treeview1_Expanded(object sender, RoutedEventArgs e) { coa = new List<string>(); //coa = (List<string>)Application.Current.Properties["CoAFull"]; HMDAC.Hmclientdb db = new HMDAC.Hmclientdb(HMBL.Helper.GetDBPath()); var data = (from a in db.CoA where a.ParentId == 0 && a.Asset == true select new { a.Asset, a.Category, a.CoAName, a.Hide, a.Recurring, a.TaxApplicable }); DataTable dtTable = new DataTable(); dtTable.Columns.Add("Asset", typeof(bool)); dtTable.Columns.Add("Category", typeof(string)); dtTable.Columns.Add("CoAName", typeof(string)); dtTable.Columns.Add("Hide", typeof(bool)); dtTable.Columns.Add("Recurring", typeof(bool)); dtTable.Columns.Add("TaxApplicable", typeof(bool)); if (data.Count() > 0) { foreach (var item in data) { DataRow dr = dtTable.NewRow(); dr["Asset"] = item.Asset; dr["Category"] = item.Category; dr["CoAName"] = item.CoAName; dr["Hide"] = item.Hide; dr["Recurring"] = item.Recurring; dr["TaxApplicable"] = item.TaxApplicable; dtTable.Rows.Add(dr); } } coa = dtTable; }

    Read the article

  • C# code to GZip and upload a string to Amazon S3

    - by BigJoe714
    Hello. I currently use the following code to retrieve and decompress string data from Amazon C#: GetObjectRequest getObjectRequest = new GetObjectRequest().WithBucketName(bucketName).WithKey(key); using (S3Response getObjectResponse = client.GetObject(getObjectRequest)) { using (Stream s = getObjectResponse.ResponseStream) { using (GZipStream gzipStream = new GZipStream(s, CompressionMode.Decompress)) { StreamReader Reader = new StreamReader(gzipStream, Encoding.Default); string Html = Reader.ReadToEnd(); parseFile(Html); } } } I want to reverse this code so that I can compress and upload string data to S3 without being written to disk. I tried the following, but I am getting an Exception: using (AmazonS3 client = Amazon.AWSClientFactory.CreateAmazonS3Client(AWSAccessKeyID, AWSSecretAccessKeyID)) { string awsPath = AWSS3PrefixPath + "/" + keyName+ ".htm.gz"; byte[] buffer = Encoding.UTF8.GetBytes(content); using (MemoryStream ms = new MemoryStream()) { using (GZipStream zip = new GZipStream(ms, CompressionMode.Compress)) { zip.Write(buffer, 0, buffer.Length); PutObjectRequest request = new PutObjectRequest(); request.InputStream = ms; request.Key = awsPath; request.BucketName = AWSS3BuckenName; using (S3Response putResponse = client.PutObject(request)) { //process response } } } } The exception I am getting is: Cannot access a closed Stream. What am I doing wrong?

    Read the article

  • Design approach, string table data, variables, stl memory usage

    - by howieh
    I have an old structure class like this: typedef vector<vector<string>> VARTYPE_T; which works as a single variable. This variable can hold from one value over a list to data like a table. Most values are long,double, string or double [3] for coordinates (x,y,z). I just convert them as needed. The variables are managed in a map like this : map<string,VARTYPE_T *> where the string holds the variable name. Sure, they are wrapped in classes. Also i have a tree of nodes, where each node can hold one of these variablemaps. Using VS 2008 SP1 for this, i detect a lot of memory fragmentation. Checking against the stlport, stlport seemed to be faster (20% ) and uses lesser memory (30%, for my test cases). So the question is: What is the best implementation to solve this requirement with fast an properly used memory ? Should i write an own allocator like a pool allocator. How would you do this ? Thanks in advance, Howie

    Read the article

  • Storing UTF8 string in a UnicodeString

    - by Mick
    In Delphi 2007 you can store a UTF8 string in a WideString and then pass that onto a Win32 function, e.g. var UnicodeStr: WideString; UTF8Str: WideString; begin UnicodeStr:='some unicode text'; UTF8Str:=UTF8Encode(UnicodeStr); Windows.SomeFunction(PWideChar(UTF8Str), ...) end; Delphi 2007 does not interfere with the contents of UTF8Str, i.e. it is left as a UTF8 encoded string stored in a WideString. But in Delphi 2010 I'm struggling to find a way to do the same thing, i.e. store a UTF8 encoded string in a WideString without it being automatically converted from UTF8. I cannot pass a pointer to UTF8 string (or RawByteString), e.g. the following will obviously not work: var UnicodeStr: WideString; UTF8Str: UTF8String; begin UnicodeStr:='some unicode text'; UTF8Str:=UTF8Encode(UnicodeStr); Windows.SomeFunction(PWideChar(UTF8Str), ...) end; Any help appreciated. Thanks.

    Read the article

  • String trouble in Rave Reports 8

    - by Jørn E. Angeltveit
    We are currently working with Delphi 2006, but we are now very ready to move on to Delphi 2010. The problem lies in our Rave reports, though... We just get to many string errors when running our reports with Rave 8. And they just don't make any sense. (The reports compile with no error, and we can even run them without any error in Rave 6.) For instance: //This event causes access violation (in rtl14.bpl) at run time { Event for Page1.OnBeforeReport } function Page1_OnBeforeReport(Self: TRavePage); var s: String; begin s := 'My text in param'; s := s + ' and som more text'; s := copy(s,1,length(s)) + ' and then some more'; RaveProject.SetParam('MyTestParam', s); end OnBeforeReport; //This event works OK { Event for Page1.OnBeforeReport } function Page1_OnBeforeReport(Self: TRavePage); var s: String; begin s := 'My text in param'; s := s + ' and som more text'; s := copy(s,1,length(s)); // + ' and then some more'; RaveProject.SetParam('MyTestParam', s); end OnBeforeReport; //This event works OK too { Event for Page1.OnBeforeReport } function Page1_OnBeforeReport(Self: TRavePage); var s: String; begin s := 'My text in param'; s := s + ' and som more text'; s := copy(s,1,length(s)) + s; RaveProject.SetParam('MyTestParam', s); end OnBeforeReport; We really want to stick to Rave, because we have a lot of reports (150+) with a lot of functionality (sql statements, events etc). Besides, we have customers who have designed their own custom reports as well. Does anybody know the reason for these errors? Is there any solution or workaround to these problems?

    Read the article

  • uninstall string

    - by Sakhawat Ali
    Hi experts, I am developing an desktop based application using VB.NET, similar to add/remove program. everything was working fine until i start working on uninstall feature. Now what am i doing is that i get the uninstall string of the specific application from the registry and use System.Diagnostics.Process to run UninstallString. Dim proc As New Process() proc.StartInfo.FileName =UninstallString proc.Start() proc.WaitForExit() proc.Close() latter i found that it only work for straight file paths only, i mean with no command line argument like: C:\program files\someApp\uninstall.exe I make a list of list of all UninstallStrings of all application installed on my machine. i found few things like application installed using MSI, some were with rundll32 and few were with straight file path with some command argument like: My Silverlight SDK UninstallString, MSI Example MsiExec.exe /X{2012098D-EEE9-4769-8DD3-B038050854D4} My JetAudio UninstallString, RunDll32 Example RunDll32 C:\PROGRA~1\COMMON~1\INSTAL~1\engine\6\INTEL3~1\Ctor.dll,LaunchSetup "C:\Program Files\InstallShield Installation Information{91F34319-08DE-457A-99C0-0BCDFAC145B9}\Setup.exe" -l0x9 My Google Chrome UninstallString, straight file path with command argument example "C:\Program Files\Google\Chrome\Application\5.0.375.55\Installer\setup.exe" -uninstall The code i mentioned above does not work for these. i did some string parsing, separate two thing from UninstallString one is Filename and other is Arguments. like for MSI, filename is MSIEXEC.EXE and argument will be rest of the string, same for RunDLL32, same for straight file path with command argument. Now what am i facing is that, after every 2 or 3 days i come to know that this type of unistallstring is also not working. and why is that not working because it is a new type maybe abc C:\program files\someapp.exe -ddd so parse it too. is there any better way of doing that rather then parsing the string.

    Read the article

  • Writing String to Stream and reading it back does not work

    - by Binary255
    I want to write a String to a Stream (a MemoryStream in this case) and read the bytes one by one. stringAsStream = new MemoryStream(); UnicodeEncoding uniEncoding = new UnicodeEncoding(); String message = "Message"; stringAsStream.Write(uniEncoding.GetBytes(message), 0, message.Length); Console.WriteLine("This:\t\t" + (char)uniEncoding.GetBytes(message)[0]); Console.WriteLine("Differs from:\t" + (char)stringAsStream.ReadByte()); The (undesired) result I get is: This: M Differs from: ? It looks like it's not being read correctly, as the first char of "Message" is 'M', which works when getting the bytes from the UnicodeEncoding instance but not when reading them back from the stream. What am I doing wrong? The bigger picture: I have an algorithm which will work on the bytes of a Stream, I'd like to be as general as possible and work with any Stream. I'd like to convert an ASCII-String into a MemoryStream, or maybe use another method to be able to work on the String as a Stream. The algorithm in question will work on the bytes of the Stream.

    Read the article

  • Strange \n in base64 encoded string in Ruby

    - by intellidiot
    The inbuilt Base64 library in Ruby is adding some '\n's. I'm unable to find out the reason. For this special example: irb(main):001:0> require 'rubygems' => true irb(main):002:0> require 'base64' => true irb(main):003:0> str = "1110--ad6ca0b06e1fbeb7e6518a0418a73a6e04a67054" => "1110--ad6ca0b06e1fbeb7e6518a0418a73a6e04a67054" irb(main):004:0> Base64.encode64(str) => "MTExMC0tYWQ2Y2EwYjA2ZTFmYmViN2U2NTE4YTA0MThhNzNhNmUwNGE2NzA1\nNA==\n" The \n's are at the last and 6th position from end. The decoder (Base64.decode64) returns back the old string perfectly. Strange thing is, these \n's don't add any value to the encoded string. When I remove the newlines from the output string, the decoder decodes it again perfectly. irb(main):005:0> Base64.decode64(Base64.encode64(str).gsub("\n", '')) == str => true More of this, I used an another JS library to produce the base64 encoded output of the same input string, the output comes without the \n's. Is this a bug or anything else? Has anybody faced this issue before? FYI, $ ruby -v ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]

    Read the article

  • Issue with getting 2 chars from string using indexer

    - by Learner
    I am facing an issue in reading char values. See my program below. I want to evaluate an infix expression. As you can see I want to read '10' , '*', '20' and then use them...but if I use string indexer s[0] will be '1' and not '10' and hence I am not able to get the expected result. Can you guys suggest me something? Code is in c# class Program { static void Main(string[] args) { string infix = "10*2+20-20+3"; float result = EvaluateInfix(infix); Console.WriteLine(result); Console.ReadKey(); } public static float EvaluateInfix(string s) { Stack<float> operand = new Stack<float>(); Stack<char> operator1 = new Stack<char>(); int len = s.Length; for (int i = 0; i < len; i++) { if (isOperator(s[i])) // I am having an issue here as s[i] gives each character and I want the number 10 operator1.Push(s[i]); else { operand.Push(s[i]); if (operand.Count == 2) Compute(operand, operator1); } } return operand.Pop(); } public static void Compute(Stack<float> operand, Stack<char> operator1) { float operand1 = operand.Pop(); float operand2 = operand.Pop(); char op = operator1.Pop(); if (op == '+') operand.Push(operand1 + operand2); else if(op=='-') operand.Push(operand1 - operand2); else if(op=='*') operand.Push(operand1 * operand2); else if(op=='/') operand.Push(operand1 / operand2); } public static bool isOperator(char c) { bool result = false; if (c == '+' || c == '-' || c == '*' || c == '/') result = true; return result; } } }

    Read the article

  • Grouping Collection seperating numeric 5 from String "5"

    - by invertedSpear
    BackGround: I have an advanced data grid. The data provider for this ADG is an ArrayCollection. There is a grouping collection on an ID field of this AC. Example of a couple items within this AC the AC var name is "arcTemplates": (mx.collections::ArrayCollection)#0 filterFunction = (null) length = 69 list = (mx.collections::ArrayList)#1 length = 69 source = (Array)#2 [0] (Object)#3 abbreviation = "sore-throat" insertDate = "11/16/2009" name = "sore throat" templateID = 234 templateType = "New Problem" templateTypeID = 1 [32] (Object)#35 abbreviation = 123 insertDate = "03/08/2010" name = 123 templateID = 297 templateType = "New Problem" templateTypeID = 1 [55] (Object)#58 abbreviation = 1234 insertDate = "11/16/2009" name = 1234 templateID = 227 templateType = "Exam" templateTypeID = 5 [56] (Object)#59 abbreviation = "breast only" insertDate = "03/15/2005" name = "breast exam" templateID = 195 templateType = "Exam" templateTypeID = 5 Example of Flex code leading to the Grouping: <mx:AdvancedDataGrid displayItemsExpanded="true" id="gridTemplates"> <mx:dataProvider> <mx:GroupingCollection id="gc" source="{arcTemplates}"> <mx:Grouping > <mx:GroupingField name="templateTypeID" compareFunction="gcSort"> GC sort function: public function gcSort(a:Object, b:Object):int{ return ObjectUtil.stringCompare(String(a.templateTypeID + a.name).toLowerCase(), String(b.templateTypeID + b.name).toLowerCase()); } Problem: In my AC example there are a few items, items 0, 32 and 56 properly sort and group to their templateTypeID, but item 55 does something weird. It seems to sort/group on the numeric 5 instead of the string "5". Gets stranger. If I change the name property to contain text (so 1234x) it then correctly sorts/groups to the string "5" Question: What is going on here and how do I fix it?

    Read the article

  • Matlab and .net problem with character string function input

    - by Peter
    I have a MATLAB function that I've compiled into a .net library. The function is a simple one that takes a character array as an input and a numeric array as output: function insert = money(dateLimit) .. insert = [1 2]; The function works fine when no function arguments are specified (a default argument is provided inside the function) Dim sf As New SpreadFinder.SpreadFinder Dim output = sf.money() As soon as an argument is specified .net complains. I'm thinking this should be easy and has been done before but searching through MATLAB documentation doesn't offer much help. Here's what I've tried. The sf.money() overload for the function with arguments is (numArgsOut as Integer, argsOut as MWArray, argsIn as MWArray) and hence that's what I've tried. What am I missing? Dim sf As New SpreadFinder.SpreadFinder Dim inputArgs(1) As Arrays.MWCharArray Dim dateLimitString As String = "some string" inputArgs(0) = New Arrays.MWCharArray(dateLimitString) Dim outputArgs(1) As Arrays.MWNumericArray outputArgs(0) = New Arrays.MWNumericArray() sf.money(1, outputArgs, inputArgs) Gives System.NullReferenceException : Object reference not set to an instance of an object. at MathWorks.MATLAB.NET.Utility.MWMCR.EvaluateFunction(String functionName, Int32 numArgsOut, Int32 numArgsIn, MWArray[] argsIn) at MathWorks.MATLAB.NET.Utility.MWMCR.EvaluateFunction(String functionName, Int32 numArgsOut, MWArray[]& argsOut, MWArray[] argsIn) at SpreadFinder.SpreadFinder.money(Int32 numArgsOut, MWArray[]& argsOut, MWArray[] argsIn)

    Read the article

  • ASP.NET application using old connection string.

    - by Doug S.
    I am trying to publish a website using ASP.NET MVC3 EF and CODEFIRST with a SQL Server 2008 backend. On my local machine I was using a sql express db for development, but now that I am pushing live, I want to use my hosted production database. The problem is that when I try to run the application, it is still using my local db connection string. I have completely removed the old connection string from my web.config file and am using the <clear /> tag before creating the new connection string. I have also cleaned the solution and rebuilt, but somehow it is still connecting to the old db. What am I missing? This is the new connection string: <connectionStrings> <clear /> <add name="CellularAutomataDBContext" connectionString=" Server=XXX; Database=CellularAutomata; User ID=XXX; Password=XXX; Trusted_Connection=False" providerName="System.Data.SqlClient" /> </connectionStrings>

    Read the article

  • JSF/Facelets: set `action` attribute to a dynamically evaluated string

    - by harto
    In my JSF/Facelets application, I want to dynamically generate a breadcrumb trail from a list of page IDs using a custom tag: <foo:breadcrumbs trail="foo,bar,baz"/> This should generate something like: <h:commandLink action="foo" ... /> <h:commandLink action="bar" ... /> <!-- (etc.) --> My code looks something like this: <ui:repeat value="#{fn:split(trail, ',')}" var="key"> <h:commandLink action="#{key}" ... /> </ui:repeat> The problem with this code is that #{key} is interpreted as a method binding. However, I just want the string value of #{key} to be returned as the navigation outcome. How can I achieve this? The only thing I could think of was creating a dummy managed-bean that has an outcome field and an action handler, and invoke it like so: <h:commandLink action="#{dummy.click}" ...> <f:setPropertyActionListener target="#{dummy.outcome}" value="#{key}" /> </h:commandLink> with the dummy class defined like so: public class Dummy { private String outcome; public String click() { return outcome; } public void setOutcome(String outcome) { this.outcome = outcome; } public void getOutcome() { return outcome; } } That seems ugly though, and I don't know if it would work.

    Read the article

  • Literal ampersands in System.Uri query string

    - by Nathan Baulch
    I'm working on a client app that uses a restful service to look up companies by name. It's important that I'm able to include literal ampersands in my queries since this character is quite common in company names. However whenever I pass %26 (the URI escaped ampersand character) to System.Uri, it converts it back to a regular ampersand character! On closer inspection, the only two characters that aren't converted back are hash (%23) and percent (%25). Lets say I want to search for a company named "Pierce & Pierce": var endPoint = "http://localhost/companies?where=Name eq '{0}'"; var name = "Pierce & Pierce"; Console.WriteLine(new Uri(string.Format(endPoint, name))); Console.WriteLine(new Uri(string.Format(endPoint, Uri.EscapeUriString(name)))); Console.WriteLine(new Uri(string.Format(endPoint, Uri.EscapeDataString(name)))); All three of the above combinations return: http://localhost/companies?where=Name eq 'Pierce & Pierce' This causes errors on the server side since the ampersand is (correctly) interpreted as a query arg delimiter. What I really need it to return is the original string: http://localhost/companies?where=Name eq 'Pierce %26 Pierce' How can I work around this behavior without discarding System.Uri entirely? I can't replace all ampersands with %26 at the last moment because there will usually be multiple query args involved and I don't want to destroy their delimiters. Note: A similar problem was discussed in this question but I'm specifically referring to System.Uri.

    Read the article

  • how to push a string address to stack with assembly, machine code

    - by Yigit
    Hi all, I am changing minesweeper.exe in order to have an understanding of how code injection works. Simply, I want the minesweeper to show a message box before starting. So, I find a "cave" in the executable and then define the string to show in messagebox and call the messagebox. Additionally of course, I have to change the value at module entry point of the executable and first direct it to my additional code, then continue its own code. So at the cave what I do; "hello starbuck",0 push 0 //arg4 of MessageBoxW function push the address of my string //arg3, must be title push the address of my string //arg2, must be the message push 0 //arg1 call MessageBoxW ... Now since the memory addresses of codes in the executable change everytime it is loaded in the memory, for calling the MessageBoxW function, I give the offset of the address where MessageBoxW is defined in Import Address Table. For instance, if MessageBoxW is defined at address1 in the IAT and the instruction just after call MessageBoxW is at address2 instead of writing call MessageBoxW, I write call address2 - address1. So my question is, how do I do it for pushing the string's address to the stack? For example, if I do these changes via ollydbg, I give the immediate address of "hello starbuck" for pushing and it works. But after reloading the executable or starting it outside of ollydbg, it naturally fails, since the immediate addresses change. Thanks in advance, Yigit.

    Read the article

  • How to decode a html string using xslt

    - by John ClearZ
    I am trying to style an rss feed using xslt. I want to display an image that is stored in the tag on the feed. The problem is it is encoded to display as text on the page instead of being rendered. The following is an example of part of the string. 1). <description>&lt;img src="http&amp;#58;&amp;#47;&amp;#47;buavhw.blu.livefilestore.com&amp;#47;y1ppCokLxFJSG2cmyPdvg... I had to add extra coding to the string above to get it to appear properly here. The string below is how it appears when I paste it directly into the text box. 2). <description><img src="http&#58;&#47;&#47;buavhw.blu.livefilestore.com&#47;y1ppCokLxFJSG2cmyPdvg... If I copy and paste it again from the preview window it only then becomes the following string. 3). <description><img src="http://buavhw.blu.livefilestore.com/y1ppCokLxFJSG2cmyPdvg...

    Read the article

  • Covert uiiamge into string

    - by Warrior
    I am new iphone development.Is there any possibility to covert the uiimage into string and then once again back to image. - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img1 editingInfo:(NSDictionary *)editInfo { [[picker parentViewController] dismissModalViewControllerAnimated:YES]; NSData *data = UIImagePNGRepresentation(img1); NSString *str1; str1 = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]; MyAppAppDelegate *appDelegate = (MyAppAppDelegate *) [[UIApplication sharedApplication] delegate]; [appDelegate setCurrentLink:str1]; EmailPictureViewController *email = [[EmailPictureViewController alloc] initWithNibName:@"EmailPictureViewController" bundle:nil]; [self.navigationController pushViewController:email animated:YES]; } so i can use delegate methods to tranfer the image from one view to another view. so i should convert the string once again to image and display it in another view. In Another view - (void)viewDidLoad { MyAppAppDelegate *appDelegate =(MyAppAppDelegate *) [[UIApplication sharedApplication] delegate]; str1 = [appDelegate getCurrentLink]; NSLog(@"The String %@",str1); NSData *aData; aData = [str1 dataUsingEncoding: NSASCIIStringEncoding]; NSLog(@"The String Data %@",aData); NSLog(@"Inside Didload3"); [imgview setImage:[UIImage imageWithData:aData]]; } But this doesn't work for me.Where do i go wrong.Is there any way to solve it?.Please help me out.Thanks.

    Read the article

  • Serializing and deserializing a map with key as string

    - by Grace K
    Hi! I am intending to serialize and deserialize a hashmap whose key is a string. From Josh Bloch's Effective Java, I understand the following. P.222 "For example, consider the case of a harsh table. The physical representation is a sequence of hash buckets containing key-value entries. Which bucket an entry is placed in is a function of the hash code of the key, which is not, in general guaranteed to be the same from JVM implementation to JVM implementation. In fact, it isn't even guranteed to be the same from run to run on the same JVM implementation. Therefore accepting the default serialized form for a hash table would constitute a serious bug. Serializing and deserializing the hash table could yield an object whose invariants were seriously corrupt." My questions are: 1) In general, would overriding the equals and hashcode of the key class of the map resolve this issue and the map can be correctly restored? 2) If my key is a String and the String class is already overriding the hashCode() method, would I still have problem described above. (I am seeing a bug which makes me think this is probably still a problem even though the key is String with overriding hashCode.) 3)Previously, I get around this issue by serializing an array of entries (key, value) and when deserializing I would reconstruct the map. I am wondering if there is a better approach. 4) If the answers to question 1 and 2 are that I still can't be guaranteed. Could someone explain why? If the hashCodes are the same would they go to the same buckets across JVMs? Thanks, Grace

    Read the article

  • C# custom control to get internal text as string

    - by Ed Woodcock
    ok, I'm working on a custom control that can contain some javascript, and read this out of the page into a string field. This is a workaround for dynamic javascript inside an updatepanel. At the moment, I've got it working, but if I try to put a server tag inside the block: <custom:control ID="Custom" runat="server"> <%= ControlName.ClientID %> </custom:control> The compiler does not like it. I know these are generated at runtime, and so might not be compatible with what I'm doing, but does anyone have any idea how I can get that working? EDIT Error message is: Code blocks are not supported in this context EDIT 2 The control: [DataBindingHandler("System.Web.UI.Design.TextDataBindingHandler, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"), ControlValueProperty("Text"), DefaultProperty("Text"), ParseChildren(true, "Text"), AspNetHostingPermission(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal), AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)] public class CustomControl : Control, ITextControl { [DefaultValue(""), Bindable(true), Localizable(true)] public string Text { get { return (string)(ViewState["Text"] ?? string.Empty); } set { ViewState["Text"] = value; } } }

    Read the article

  • Setting String as Image Source in C#

    - by Dan
    UPDATE: Okay I've changed my code to this: if (appSettings.Contains("image")) { Uri uri = new Uri( (string)appSettings["image"] + ".jpg", UriKind.Absolute); ImageSource imgSource = new BitmapImage(uri); myImage.Source = imgSource; } else { Uri uriDefault = new Uri("default.jpg", UriKind.Absolute); ImageSource imgSourceDefault = new BitmapImage(uriDefault); myImage.Source = imgSourceDefault; } But now I get "Invalid URI: The format of the URI could not be determined". Well I've looked up several methods to fix this in my Windows Phone 7 app but I can't seem to find anything that works. What confuses me is that I've done something just like this before with no problem, so I'm not sure why it's not working. The code causing me the problem is this: if (appSettings.Contains("image")) { myImage.Source = (string)appSettings["image"]; } else { myImage.Source = "default.jpg"; } The error I get is this "Cannot implicitly convert type 'string' to 'System.Windows.Media.ImageSource". The reason this confuses me is because I did this Twitter app tutorial: http://weblogs.asp.net/scottgu/archive/2010/03/18/building-a-windows-phone-7-twitter-application-using-silverlight.aspx , in which you bind the image source directly to a string. So what can I do to remedy this?

    Read the article

  • Latex - Apply an operation to every character in a string

    - by hroest
    Hi I am using LaTeX and I have a problem concerning string manipulation. I want to have an operation applied to every character of a string, specifically I want to replace every character "x" with "\discretionary{}{}{}x". I want to do this because I have a long string (DNA) which I want to be able to separate at any point without hyphenation. Thus I would like to have a command called "myDNA" that will do this for me instead of inserting manually \discretionary{}{}{} after every character. Is this possible? I have looked around the web and there wasnt much helpful information on this topic (at least not any I could understand) and I hoped that you could help. --edit To clarify: What I want to see in the finished document is something like this: the dna sequence is CTAAAGAAAACAGGACGATTAGATGAGCTTGAGAAAGCCATCACCACTCA AATACTAAATGTGTTACCATACCAAGCACTTGCTCTGAAATTTGGGGACTGAGTACACCAAATACGATAG ATCAGTGGGATACAACAGGCCTTTACAGCTTCTCTGAACAAACCAGGTCTCTTGATGGTCGTCTCCAGGT ATCCCATCGAAAAGGATTGCCACATGTTATATATTGCCGATTATGGCGCTGGCCTGATCTTCACAGTCAT CATGAACTCAAGGCAATTGAAAACTGCGAATATGCTTTTAATCTTAAAAAGGATGAAGTATGTGTAAACC CTTACCACTATCAGAGAGTTGAGACACCAGTTTTGCCTCCAGTATTAGTGCCCCGACACACCGAGATCCT AACAGAACTTCCGCCTCTGGATGACTATACTCACTCCATTCCAGAAAACACTAACTTCCCAGCAGGAATT just plain linebreaks, without any hyphens. The DNA sequence will be one long string without any spaces or anything but it can break at any point. This is why my idea was to inesert a "\discretionary{}{}{}" after every character, so that it can break at any point without inserting any hyphens.

    Read the article

  • Cross-platform iteration of Unicode string

    - by kizzx2
    I want to iterate each character of a Unicode string, treating each surrogate pair and combining character sequence as a single unit (one grapheme). Example The text "??????" is comprised of the code points: U+0928, U+092E, U+0938, U+094D, U+0924, U+0947, of which, U+0938 and U+0947 are combining marks. static void Main(string[] args) { const string s = "??????"; Console.WriteLine(s.Length); // Ouptuts "6" var l = 0; var e = System.Globalization.StringInfo.GetTextElementEnumerator(s); while(e.MoveNext()) l++; Console.WriteLine(l); // Outputs "4" } So there we have it in .NET. We also have Win32's CharNextW() #include <Windows.h> #include <iostream> #include <string> int main() { const wchar_t * s = L"??????"; std::cout << std::wstring(s).length() << std::endl; // Gives "6" int l = 0; while(CharNextW(s) != s) { s = CharNextW(s); ++l; } std::cout << l << std::endl; // Gives "4" return 0; } Question Both ways I know of are specific to Microsoft. Are there portable ways to do it? I heard about ICU but I couldn't find something related quickly (UnicodeString(s).length() still gives 6). Would be an acceptable answer to point to the related function/module in ICU. C++ doesn't have a notion of Unicode, so a lightweight cross-platform library for dealing with these issues would make an acceptable answer.

    Read the article

  • Instrumenting a string

    - by George Polevoy
    Somewhere in C++ era i have crafted a library, which enabled string representation of the computation history. Having a math expression like: TScalar Compute(TScalar a, TScalar b, TScalar c) { return ( a + b ) * c; } I could render it's string representation: r = Compute(VerbalScalar("a", 1), VerbalScalar("b", 2), VerbalScalar("c", 3)); Assert.AreEqual(9, r.Value); Assert.AreEqual("(a+b)*c==(1+2)*3", r.History ); C++ operator overloading allowed for substitution of a simple type with a complex self-tracking entity with an internal tree representation of everything happening with the objects. Now i would like to have the same possibility for NET strings, only instead of variable names i would like to see a stack traces of all the places in code which affected a string. And i want it to work with existing code, and existing compiled assemblies. Also i want all this to hook into visual studio debugger, so i could set a breakpoint, and see everything that happened with a string. Which technology would allow this kind of things? I know it sound like an utopia, but I think visual studio code coverage tools actually do the same kind of job while instrumenting the assemblies.

    Read the article

  • Fast find object by string property

    - by Andrew Kalashnikov
    Hello, colleagues. I've got task to fast find object by its string property. Object: class DicDomain { public virtual string Id{ get; set; } public virtual string Name { get; set; } } For storing my object I use List[T] dictionary where T is DicDomain for now . I've got 5-10 such lists, which contain about 500-20000 at each one. Task is find objects by its Name. I use next code now: List<T> entities = dictionary.FindAll(s => s.Name.Equals(word, StringComparison.OrdinalIgnoreCase)); I've got some questions: Is my search speed optimal. I think now. Data structure. It List good for this task. What about hashtable,sorted... Method Find. May be i should use string intern?? I haven't much exp at these tasks. Can u give me good advice for increase perfomance. Thanks

    Read the article

< Previous Page | 122 123 124 125 126 127 128 129 130 131 132 133  | Next Page >