I have a richtextbox which I want the "literal" rtf of.
richtextbox.rtf returns
{\\rtf1\\ansi\\ ansicpg1252\\de ff0\\deflang103 3\\uc1 }\r\n\0
when i put this into a string I get
"{\\rtf1\\ansi\ \ansicpg1252\\d eff0\\deflang10 33\\uc1 }\r\n\0"
I want this to be
@"{\\rtf1\\ansi \\ansicpg1252\\ deff0\\deflang1 033\\uc1 }\r\n\0"
to treat the escape characters as literals
How can I do this?
TIA
JB
*Rubs eyes and stares blankly at screen* 5 3021
"John Baro" <jo***@NixSpaMi primus.com.au.c om.au> wrote in message
news:2h******** ****@uni-berlin.de... I have a richtextbox which I want the "literal" rtf of. richtextbox.rtf returns {\\rtf1\\ansi\\ ansicpg1252\\de ff0\\deflang103 3\\uc1 }\r\n\0
when i put this into a string I get "{\\rtf1\\ansi\ \ansicpg1252\\d eff0\\deflang10 33\\uc1 }\r\n\0"
What do you mean by "put this into a string"?
I want this to be @"{\\rtf1\\ansi \\ansicpg1252\\ deff0\\deflang1 033\\uc1 }\r\n\0" to treat the escape characters as literals
How can I do this?
Can you explain a little more about how to demonstrate the problem and why
you think something is going wrong?
Hi Michael
"Michael A. Covington" <lo**@www.covin gtoninnovations .com.for.addres s> wrote
in message news:ub******** ******@tk2msftn gp13.phx.gbl... "John Baro" <jo***@NixSpaMi primus.com.au.c om.au> wrote in message news:2h******** ****@uni-berlin.de... I have a richtextbox which I want the "literal" rtf of. richtextbox.rtf returns {\\rtf1\\ansi\\ ansicpg1252\\de ff0\\deflang103 3\\uc1 }\r\n\0
when i put this into a string I get "{\\rtf1\\ansi\ \ansicpg1252\\d eff0\\deflang10 33\\uc1 }\r\n\0"
What do you mean by "put this into a string"?
string s = MyRtb.RTF; I want this to be @"{\\rtf1\\ansi \\ansicpg1252\\ deff0\\deflang1 033\\uc1 }\r\n\0" to treat the escape characters as literals
How can I do this?
Can you explain a little more about how to demonstrate the problem and why you think something is going wrong?
I want to perform a regex match on the rtf but without the @ at the
beginning of the string, indicating its a literal, I think the regex match
is treating the \\ as a single \. ( I can match on a single \ instead of the
escaped double but I would prefer to match on the literal string)
When I put \n for instance into the rtb then the text property is @"\n",
indicating that \n is a literal, not a newline command.
Take this text
@"\n"
is the same as
"\\n"
/*
@"\\n"
is the same as
\\\\n
I hope this is clearer.
Cheers
JB
Slightly clearer... but I haven't worked with regexes myself.
What I know is that "abc" and @"abc" are not two kinds of strings. They are
two different things you can do to put the same sequence of characters (a,
b, c) into memory. Likewise, "\\" and @"\" are not two different strings;
they are two ways of writing the same string.
So asking how to put the @ at the beginning is not the right question. When
it's in the computer's memory, the string neither has nor lacks the initial
@ or the quotation marks. It is just a series of characters.
It sounds like your question has to do with how regexes handle backslashes,
and, alas, I don't know the answer.
"John Baro" <jo***@NixSpaMi primus.com.au.c om.au> wrote in message
news:2h******** ****@uni-berlin.de... Hi Michael
"Michael A. Covington" <lo**@www.covin gtoninnovations .com.for.addres s>
wrote in message news:ub******** ******@tk2msftn gp13.phx.gbl... "John Baro" <jo***@NixSpaMi primus.com.au.c om.au> wrote in message news:2h******** ****@uni-berlin.de... I have a richtextbox which I want the "literal" rtf of. richtextbox.rtf returns {\\rtf1\\ansi\\ ansicpg1252\\de ff0\\deflang103 3\\uc1 }\r\n\0
when i put this into a string I get "{\\rtf1\\ansi\ \ansicpg1252\\d eff0\\deflang10 33\\uc1 }\r\n\0" What do you mean by "put this into a string"?
string s = MyRtb.RTF;
I want this to be @"{\\rtf1\\ansi \\ansicpg1252\\ deff0\\deflang1 033\\uc1 }\r\n\0" to treat the escape characters as literals
How can I do this?
Can you explain a little more about how to demonstrate the problem and
why you think something is going wrong?
I want to perform a regex match on the rtf but without the @ at the beginning of the string, indicating its a literal, I think the regex
match is treating the \\ as a single \. ( I can match on a single \ instead of
the escaped double but I would prefer to match on the literal string)
When I put \n for instance into the rtb then the text property is @"\n", indicating that \n is a literal, not a newline command.
Take this text
@"\n" is the same as "\\n" /*
@"\\n" is the same as \\\\n
I hope this is clearer. Cheers JB
"Michael A. Covington" <lo**@www.covin gtoninnovations .com.for.addres s> wrote
in message news:es******** *****@TK2MSFTNG P11.phx.gbl... Slightly clearer... but I haven't worked with regexes myself.
What I know is that "abc" and @"abc" are not two kinds of strings. They
are two different things you can do to put the same sequence of characters (a, b, c) into memory. Likewise, "\\" and @"\" are not two different strings; they are two ways of writing the same string.
Yes :)
So asking how to put the @ at the beginning is not the right question.
When it's in the computer's memory, the string neither has nor lacks the
initial @ or the quotation marks. It is just a series of characters.
However. Once we have a string that is not a "literal" string. How can we
convert it to a "literal" string.
ie
string s = @"\\n\t";
string x = "\\n\t";
string p = s;
string t = x;
How can we make x = equal @"\\n\t" without setting x to s;
This might work
t = x.Replace(@"\", @"\\"); //Nope, only replaces the first "\" because it
treats the \t as a tab char
It sounds like your question has to do with how regexes handle
backslashes, and, alas, I don't know the answer.
I was actually wrong to be testing for double forward slashes. The string
has already been escaped so I should test for single ones :) (which works)
I am still curious to know how to convert an escaped string into a literal
string so that by the above example we have t equal to "\\\\n\\t" or
@"\\n\t"
(Cant think why you would want to do this but am still curious :)
Cheers
JB "John Baro" <jo***@NixSpaMi primus.com.au.c om.au> wrote in message news:2h******** ****@uni-berlin.de... Hi Michael
"Michael A. Covington" <lo**@www.covin gtoninnovations .com.for.addres s> wrote in message news:ub******** ******@tk2msftn gp13.phx.gbl... "John Baro" <jo***@NixSpaMi primus.com.au.c om.au> wrote in message news:2h******** ****@uni-berlin.de... > I have a richtextbox which I want the "literal" rtf of. > richtextbox.rtf returns > {\\rtf1\\ansi\\ ansicpg1252\\de ff0\\deflang103 3\\uc1 }\r\n\0 > > when i put this into a string I get > "{\\rtf1\\ansi\ \ansicpg1252\\d eff0\\deflang10 33\\uc1 }\r\n\0"
What do you mean by "put this into a string"?
string s = MyRtb.RTF;
> I want this to be > @"{\\rtf1\\ansi \\ansicpg1252\\ deff0\\deflang1 033\\uc1 }\r\n\0" > to treat the escape characters as literals > > How can I do this?
Can you explain a little more about how to demonstrate the problem and why you think something is going wrong?
I want to perform a regex match on the rtf but without the @ at the beginning of the string, indicating its a literal, I think the regex match is treating the \\ as a single \. ( I can match on a single \ instead of the escaped double but I would prefer to match on the literal string)
When I put \n for instance into the rtb then the text property is @"\n", indicating that \n is a literal, not a newline command.
Take this text
@"\n" is the same as "\\n" /*
@"\\n" is the same as \\\\n
I hope this is clearer. Cheers JB
> However. Once we have a string that is not a "literal" string. How can we convert it to a "literal" string.
ie
string s = @"\\n\t"; <--- that is: s contains backslash backslash n
backslash t string x = "\\n\t"; <--- that is: x contains backslash newline tab string p = s; string t = x;
How can we make x = equal @"\\n\t" without setting x to s;
Ah! You're wanting to insert all the escape characters into a string that
needs them.
I am still curious to know how to convert an escaped string into a literal string so that by the above example we have t equal to "\\\\n\\t" or @"\\n\t" (Cant think why you would want to do this but am still curious :)
This might work t = x.Replace(@"\", @"\\"); //Nope, only replaces the first "\" because it treats the \t as a tab char
Or rather because the elements of x *are* already backslash, newline, tab.
It's not a matter of how they get "treated".. . That's the reason for my
harping on the distinction between the contents of a string and the notation
with which it is written.
What you want is to go through the string and replace:
backslash with double backslash
newline with backslash n
tab with backslash t
return with backslash r
and a number of others. These are all separate replacements. There is no
shortcut, because there is no physical attribute of a tab or a newline that
makes it map onto \t or \n respectively; those are arbitrary codes.
This of course makes it a different string which a regex routine might use
to recognize newlines and tabs, even though it doesn't have any newlines and
tabs in it. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: na1paj |
last post by:
here's a simple linked list program. the DeleteNode function is
producing an infinit loop i think, but i can't figure out where..
#include <stdio.h>
typedef struct
{
char *str; //str is a dynamic array of characters
int length; //number of characters
} String;
|
by: Alan Silver |
last post by:
Hello,
I am having a problem setting and resetting cookies. I'm sure I just
doing something really stupid as this is such a basic issue, but I can
find any answer. Please can someone help me?
The following code is a complete page that demonstrates my problem. If
you save this as an .aspx and load it in a browser, it tells you it is
creating the cookie. If you reload the page, it tells you it is changing
the value. If you reload it...
|
by: serge calderara |
last post by:
Dear all,
I need to build a web application which will contains articles (long or short)
I was wondering on what is the correct way to retrive those article on web
page.
In orther words, when there is such information to be displayed are they
coming from imported files, database ?
Where and how this type of information is stored ?
What is the way to retrieve such information in order to display it in page ?
|
by: GeezerButler |
last post by:
I am really sorry if this sounds stupid. Namespace is just not my cup
of tea.
Could anybody tell me what is wrong with this xsd file (It has
something wrong with the namespaces)
I am getting the error "The element 'Books' is used but not declared in
the DTD/Schema."
If I remove targetNamespace="http://calendar/aiman" and
|
by: rdrink |
last post by:
I am just getting into pysqlite (with a fair amount of Python and MySQL
experience behind me) and have coded a simple test case to try to get
the hang of things...
yet have run into a 'stock simple' problem...
I can create a database 'test.db', add a table 'foo' (which BTW I
repeatedly DROP on each run) with one INTGER column 'id', and can
insert data into with:
cur.execute("INSERT INTO foo (id) VALUES (200)")
con.commit()
| |
by: Alberto Salvati |
last post by:
Hi, List.
My company has a VERY BIG product base on db2 udb v7.x.
We want to di an upgrade to v9, but.... current db has a lot of
procedure (cobol..!).
Therefore, we've planned to rewrite this code in sql or other language.
My (stupid, i think..) question is:
someone know a "thing" (wizard, tool, application..) helpful to reduce
needed work to convert/transform cobol code?
For example, a tool that dows a reverse enigineering of...
|
by: diSangro |
last post by:
Hello community,
I have a stupid question...of course Im not expert of csh scripting
I couldn't get how to compose a string in a csh script.
suppose I have:
set STR1 = "text1"
set STR2 = "text2"
|
by: MaxMax |
last post by:
I want to add a text to another text using regular expressions... An example
before= "foo"
after= "foobar"
before= "one"
after= "onebar"
before = ""
after = "bar"
|
by: Phillip Taylor |
last post by:
Hi guys, I'm looking to develop a simple web service in VB.NET but I'm
having some trivial issues. In Visual Studio I create a web services
project and change the asmx.vb file to this:
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
<System.Web.Services.WebService(Namespace:="http://
wwwpreview.#deleted#.co.uk/~ptaylor/Customer.wsdl")_
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |