excel - Dealing with character limits on Strings

Cells can contain a large amount of characters. I'm not sure about the limit but I am testing with 450+ characters. In VBA, I have no problem inserting the value of that cell in a string, reading it via debug.print, using functions on it such as Len(str) in order to find the character count.My problemThe string I want to play with are HTML strings on which I apply the format and then remove HTML tags. The formats apply with no problem, using a macro I don't think is necessary to show (it's long) but when comes the time to remove HTML tags, I ru...Read more

user interface - Can't convert string to ui text in unity

I have looked around for solutions but nothing has worked so far, here is my code:using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEngine.UI;public class BirdController : MonoBehaviour { public float jumpVelocity; public Text jumpCooldownDisplayText = ""; public float speed = 18; private Rigidbody rb; public float jumpCooldown = 0f; // Use this for initialization void Start () { rb = GetComponent<Rigidbody>(); } // Update is called once per frame void FixedUpdat...Read more

Iterate through a string and slice it - index error - Python

i am trying to iterate though a string and check if the consecutive characters are the same. If not i want to inset a space between them. Then store this new string in the Mynewstring until the while loop goes through all characters.I am posting a While loop, a tried this also with a For loop, to the same result. Any help will be appreciated!mystr = '77445533'mynewstring = ""myind = 0while myind < len(mystr)+1: if mystr[myind] != mystr[myind +1]: mynewstring = mystr[:(myind)] + " " + mystr[(myind+1):] myind+=1print(mynewstring)...Read more

string - keyError, When import data in openerp

File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140112_001021-py2.7.egg/openerp/osv/osv.py", line 199, in execute res = self.execute_cr(cr, uid, obj, method, *args, **kw) File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140112_001021-py2.7.egg/openerp/osv/osv.py", line 187, in execute_cr return getattr(object, method)(cr, uid, *args, **kw) File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140112_001021-py2.7.egg/openerp/addons/base_import/models.py", line 219, in parse_preview fields = self.get_fields(cr...Read more

Why is it discouraged to accept a reference to a String (&String), Vec (&Vec), or Box (&Box) as a function argument?

I wrote some Rust code that takes a &String as an argument: fn awesome_greeting(name: &String) { println!("Wow, you are awesome, {}!", name);}I've also written code that takes in a reference to a Vec or Box:fn total_price(prices: &Vec<i32>) -> i32 { prices.iter().sum()}fn is_even(value: &Box<i32>) -> bool { **value % 2 == 0}However, I received some feedback that doing it like this isn't a good idea. Why not?...Read more

How to match a String against string literals in Rust?

I'm trying to figure out how to match a String in Rust. I initially tried matching like this, but I figured out Rust cannot implicitly cast from std::string::String to &str. fn main() { let stringthing = String::from("c"); match stringthing { "a" => println!("0"), "b" => println!("1"), "c" => println!("2"), }}This has the error:error[E0308]: mismatched types --> src/main.rs:4:9 |4 | "a" => println!("0"), | ^^^ expected struct `std::string::String`, found reference | = note: ex...Read more

vector - How to convert a Vec<Vec<f64>> into a string

I am new to Rust, and I am struggling with a simple task. I'd like to convert a matrix into a string, with the fields separated by tabs. I think this is possible by using the map function or something similar, but right now whatever I try gives me an error.This is what I have, and I'd like to convert the col part into function, which returns a tab separated string, which I can print.In Python this is something like row.join("\t"). Is there something similar in Rust?fn print_matrix(vec: &Vec<Vec<f64>>) { for row in vec.iter() ...Read more

rust - Concat String and convert them to &str

fn lyrics_more_bottles(song_template: &mut String, number: i32) { let mut template_partials = HashMap::new(); let mut start_num = number.to_string(); let mut remaining_num = (number - 1).to_string(); template_partials.insert("start", start_num + " bottles"); template_partials.insert("repeat", start_num + " bottles"); template_partials.insert("remaining", remaining_num + " bottles"); template_partials.insert("message", "Take one down and pass it around"); resolve_template(song_template, template_partials);}I can't man...Read more

string - Convert a Vec<u16> or Vec<WCHAR> to a &str

I'm getting into Rust programming to realize a small program and I'm a little bit lost in string conversions.In my program, I have a vector as follows:let mut name: Vec<winnt::WCHAR> = Vec::new(); WCHAR is the same as a u16 on my Windows machine. I hand over the Vec<u16> to a C function (as a pointer) which fills it with data. I then need to convert the string contained in the vector into a &str. However, no matter, what I try, I can not manage to get this conversion working. The only thing I managed to get working is to conver...Read more

rust - Why does a &str not coerce to a &String when using Vec::contains?

A friend asked me to explain the following quirk in Rust. I was unable to, hence this question:fn main() { let l: Vec<String> = Vec::new(); //let ret = l.contains(&String::from(func())); // works let ret = l.contains(func()); // does not work println!("ret: {}", ret);}fn func() -> & 'static str { "hello"}Example on the Rust PlaygroundThe compiler will complain like this:error[E0308]: mismatched types --> src/main.rs:4:26 |4 | let ret = l.contains(func()); // does not work | ^^^...Read more

How to check if a string contains a substring in Rust?

I'm trying to find whether a substring is in a string. In Python, this involves the in operator, so I wrote this code:let a = "abcd";if "bc" in a { do_something();}I get a strange error message:error: expected `{`, found `in` --> src/main.rs:3:13 |3 | if "bc" in a { | _____________-^4 | | do_something();5 | | } | |_____- help: try placing this code inside a block: `{ a <- { do_something(); }; }`The message suggests that I put it in a block, but I have no idea how to do that....Read more