How can I encode strings on UTF-16BE format in PHP? For "Demo Message!!!" the encoded string should be '00440065006D006F0020004D00650073007300610067006'. Also, I need to encode Arabic characters to this format.
I'm implementing serial key functionality in my application. User needs to enter at least 64bit number in order to register the application. Because typing number like 9,223,372,036,854,775,807 will take a while I want to compress it a bit. The first guess was to code this number hexadecimally but it still is quite long (0x7FFF FFFF FFFF FFFF).
Is there any standard method in .NET to code this number alphanumerically using for example: digits, upper-case and lower-case characters?
I have the requirement that in a textbox a user can jump to the next word enclosed in [] on a tab out
for example
Hi [this] is [an] example. Testing [this]
So when my cursor is at Hi and I do a tab out , the characters enclosed in the [this] are highlighted
and when I again do a tabl out th next characters enclosed in following [an] are highlighted.
This works fine
Now the requirement is whatever the text including the special chars between [] needs to be highlighted
case 1: when I have trailing ]]], it only highlights leading [[[ and ignores ]]]]
e.g
case 2: In case of multiple trailing ] e.e [this]]]] is [test], ideally one a single tabl out from this , it should go to next text enclosed in [] but a user has to tab out 4 times one tab per training ] to go to next [text]
strong text
The code is
$(document).ready(function() {
$('textarea').highlightTextarea({
color : '#0475D1',
words : [ "/(\[.*?\])/g" ],
textColor : '#000000'
});
$('textarea').live('keydown', function(e) {
var keyCode = e.keyCode || e.which;
if (keyCode == 9) {
var currentIndex = getCaret($(this).get(0))
selectText($(this), currentIndex);
return false;
}
});
});
function selectText(element, currentIndex) {
var rSearchTerm = new RegExp(/(\[.*?\])/);
var ind = element.val().substr(currentIndex).search(rSearchTerm)
currentIndex = (ind == -1 ? 0 : currentIndex);
ind = (ind == -1 ? element.val().search(rSearchTerm) : ind);
currentIndex = (ind == -1 ? 0 : currentIndex);
var lasInd = (element.val().substr(currentIndex).search(rSearchTerm) == -1 ? 0
: element.val().substr(currentIndex).indexOf(']'));
var input = element.get(0);
if (input.setSelectionRange) {
input.focus();
input.setSelectionRange(ind + currentIndex, lasInd + 1 + currentIndex);
} else if (input.createTextRange) {
var range = input.createTextRange();
range.collapse(true);
range.moveEnd('character', lasInd + 1 + currentIndex);
range.moveStart('character', ind + currentIndex);
range.select();
}
}
function getCaret(el) {
if (el.selectionEnd) {
return el.selectionEnd;
} else if (document.selection) {
el.focus();
var r = document.selection.createRange();
if (r == null) {
return 0;
}
var re = el.createTextRange(), rc = re.duplicate();
re.moveToBookmark(r.getBookmark());
rc.setEndPoint('EndToStart', re);
return rc.text.length;
}
return 0;
}
Please let me know to handle two above cases
I'm working on a logging system for my 2D engine, and I'm confused on how I should go about creating/editing the file, and how I should output that file.
I've learned that XML is more of a data carrier rather than a data displayer like HTML is. I've read that I can use XML to HTML converters. One method I've thought about is writing characters to a file in HTML.
Clarity on these matters is what I ask of you, stack overflow.
Hello,
I was wondering if it was possible to get a tag's contents only if has a given length (say, 300 characters) using XPath. Any help is welcome.
Thanks in advance
I need your help to solve this program ...
Implement a separate chaining hash table that stores strings. You’ll need a hash function that converts string into an index number. Assume the strings will be lowercase words, so 26 characters will suffice.
Hi,
Given a string like String a="- = - - What is your name?";
How to remove the leading equal, dash, space characters, to get the clean text,
"What is your name?"
Thanks.
I have a url /embed?t=X and I want to redirect it to /page/embed/X where X is any number of alpha numeric characters.
I know must redirect rules go the other way but for the purpose of the applciation I need to reverse it.
Any ideas?
I have tried things like:
RedirectRule ^embed\?t\=([a-zA-Z0-9]+)$ /page/embed/$1
but with no luck.
I have a ASP.NET solution in Visual Studio 2008 and I added a file identical to http://plugins.jquery.com/files/jquery.cookie.js.txt named jquery.cookie.js in a subfolder of my project containing other javascript files and Visual Studio is treating it as a C# file, giving me errors like CS1012: Too many characters in character literal and Semicolon after method or accesssor block is not valid.
Why?
Using the local dev server, I can use ';' in urls, but as soon as I try the live version hosted by Google, it looks like the ';' and everything afterward is stripped (at least according to request.path_qs).
(I would prefer not to encode them if possible, it's much less user friendly if the url cannot be constructed by copy-pasting, especially since other characters works fine, e.g. ':').
somehow couldn't find this with a google search, but I feel like it has to be simple...I need to convert a string to a fixed-length byte array, e.g. write "asdf" to a byte[20] array. the data is being sent over the network to a c++ app that expects a fixed-length field, and it works fine if I use a BinaryWriter and write the characters one by one, and pad it by writing '\0' an appropriate number of times.
is there a more appropriate way to do this?
I write regular expression for alphanumerics, but it is not taking space.
I want space (whitespace between characters).
I write like this:
^[a-zA-Z0-9_]*$
I write regular expression for alphanumerics, but it is not taking space.
I want space (whitespace between characters).
I write like this:
^[a-zA-Z0-9_]*$
Hello everone,
I am using preg_match() function only to allow specific charachters to accept. It is allowing all alphabates and numbers but along with that i also want to allow utf-8 characters such as "ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ" so how can i allow this charachters from preg_match() function.Plase suggest me. Thanks in advance.
Regards
Shri
When do I execute query COPY TO ... CSV, I create CSV file. BUt when open it column with names in excel that should be with national characters are not as it should be. So my question is, If it is possible within a sql query to change this encoding to utf8? Or something else? Because I want that new created CSV file to be as final product for user on web. I hope someone understood what I want:)
Is there a way to find all possible start positions for a regex match in perl?
For example, if your regex was "aa" and the text was "aaaa", it would return 0, 1, and 2, instead of, say 0 and 2.
Obviously, you could just do something like return the first match, and then delete all characters up to and including that starting character, and perform another search, but I'm hoping for something more efficient.
Hi all,
I'm not very familiar with the many-to-many insertion process using Entity Framework 4, POCO. I have a blog with 3 tables: Post, Comment, and Tag. A Post can have many Tags and a Tag can be in many Posts. Here are the Post and Tag models:
public class Tag
{
public int Id { get; set; }
[Required]
[StringLength(25, ErrorMessage = "Tag name can't exceed 25 characters.")]
public string Name { get; set; }
public virtual ICollection<Post> Posts { get; set; }
}
public class Post
{
public int Id { get; set; }
[Required]
[StringLength(512, ErrorMessage = "Title can't exceed 512 characters")]
public string Title { get; set; }
[Required]
[AllowHtml]
public string Content { get; set; }
public string FriendlyUrl { get; set; }
public DateTime PostedDate { get; set; }
public bool IsActive { get; set; }
public virtual ICollection<Comment> Comments { get; set; }
public virtual ICollection<Tag> Tags { get; set; }
}
Now when I'm adding a new post, I'm not sure what would be the right way to do. I'm thinking that I'll have a textbox where I can select multiple tags for that post (this part is already done), in my controller, I will check to see if the tag is already exists or not, if not, then I will insert the new tag. But I'm not even sure based on the models that I've created for EF, will they create a PostsTags table, or they are creating just a Tags and a Posts table and links between the two?
How would I insert the new Post and set the tags to that post? Is it just newPost.Tags = Tags (where Tags are the one that got selected, do I even need to check to see if they already exists?), and then something like _post.Add(newPost);?
Thanks.
Hi everyone. I'd ideally like a vim answer to this:
I want to change
[*, 1, *, *] to [*, 2, *, *]
Here the stars refer to individual characters in the substring, which I would like to keep unchanged. For example
[0, 1, 0, 1] to [0, 2, 0, 1]
[1, 1, 1, 1] to [1, 2, 1, 1]
If people know how to do this in perl or python or whatever, that would be equally good.
Cheers
I want someone to type words in the console, and autocomplete from a list when they hit "tab" key. However, raw_input won't return a string until someone hits [Enter].
How do I read characters into a variable until the user hits [Enter]?
*Note: I don't want to use import readline for autocompletion because of OS issues.
Hello all,
I have a JavaScript variable that I echo out using PHP which is shown like this in the page source:
var db_1 = 'C:\this\path';
When I set the value of a text field with that variable like so:
$('#myinput').val(db_1);
The slashes have disappeared and only the other characters are left!
Why is this and how can I put the slashes back in??
Thanks all
We have a problem in cloning a repository created in unix in to a Windows box.
Git fails while checking out a lengthy file that has more than 32 characters in windows.
The file name is given below.
BaseFCS_x0020_OnLine_x0020_Identicheck_x0020_verification_x0020_serviceConsumer.java*
Is there a way to fix this issue in Git?
I wrote a html scraper to scrape my various social identites, so I can make a real time 'biography' website.
However after using php curl_exec, I find that texts that I have quoted, end up being formatted in a weird character set.
ex: "I love dogs" gets formatted to ’I love dogs ’
"I hate cheese" gets formatted to “I hate cheese�
How do I either scrub these characters, or set curl not to format quotes like this.
Also, I have turned off magic_quotes.
After upgrading to the latest Rails version the path used by the image_tag helper is messed up with these characters: /%5C%22 \%22
http://localhost:3000/%5C%22/uploads/f0b07364-90bb-11/de-a278-0019dbf8d19d/Neues_LOGO_unten_mini.JPG?1275396335\%22
RAILSENV is development.
Anyone having the same problem?
Hello,
I need to rename all the files in a directory. Some examples of the source filenames are:
alpha--sometext.381928
comp--moretext.7294058
The resultant files would be renamed as:
alpha.sometext.381928
comp.moretext.7294058
The number of characters before and after the -- is not consistant.
The script needs to work on current installations of Ubuntu and FreeBSD. These are lean LAMP servers so only the necessary packages have been installed.
Thanks