How to change encoding in .net maui? - c#

I'm trying to write an app by using .net maui.
When I use Ukrainian letters I get an error.
As far as I understand, this problem can be solved by changing encoding, but I don't know how to do this correctly.
I'm trying to change encoding to windows1251 in appshell, but it wasn't successful. Maybe I forgot something.

Related

Connect to Advantage Database .add in Visual Studio .net

I'm using Visual Studio .net and would like to make a simple web application using MVC. However, I am having an extremely difficult time finding good documentation on connecting to an Advantage Database. I've installed Advantage.Data.Provider and tried to connect using the example connection strings but I can't seem to get it to work.
I've tried to dumb it down to see if I can even connect and created a console app exactly how the example here works.
https://devzone.advantagedatabase.com/dz/webhelp/advantage10/index.html?dotnet_quick_start.htm
But I get an exception :
"System.NotSupportedException: 'No data is available for encoding
1252. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.'"
The only solutions I've found have led me to using System.Text.Encoding which I can't even get the app to recognize after loading the NuGet package.
I'd love a simple tutorial on a getting any .net connection string to work.
try to download and install this
http://devzone.advantagedatabase.com/dz/content.aspxKey=20&Release=19&Product=12&Platform=11,
I was in the same situation yesterday, and it unlocked me !

Entity Framework Cyrillic displayed as question marks

I am writing an application and I am using Entity Framework and MSSQL. I have some cyrillic data(Bulgarian, if that matters) in the database. Problem is when I try to read it from the program I get question marks(?????????) but when I try from SQL Management studio everything shows up fine. Collation is set to Cyrillic_General_CI_AS and I am using nvarchar for the columns I store cyrillic characters in. I need your help. How can I fix this?
I found the solution. It turns out that the data that comes out of the database is perfectly fine. The problem was in the displaying. I was using a console project for testing and it apparently didn't like the cyrillic font. Changing the font of the console fixed my problem.

Parsing PCL for Text

Ok, so I know this is a crappy question but it has been driving me crazy all day...
I have a bunch of files containing raw PCL6/PCL XL code from printing jobs run to our printers. What I need to be able to do is somehow parse them so I can search for specific text.
Does anyone know if this is possible or understand PCL enough to suggest a reason why even on basic prints from say notepad the raw text doesn't seem to be visible within the code?
I suppose I should mention, I need to be able to code this into my C# app. Manual converters or the ability to print the pcl is not going to do what I want.
#mcalex is correct, PCL 6 (PCLXL) is a compiled binary. You can't read it. You need something that can decompile for you. Pagetech have some solutions for this. You could also look to convert to some other format where the data might be more readable. If the source could be generated in PCL 5 or PS you "might" have a better chance or reading the data directly (although not likely).

C# console font

I cannot find out which font the console app uses by default? Is it guaranteed that everyone has that font (when running this .NET app)? Want to display some unicode chars and need to be sure they are present within that font.
Thanks
I strongly recommend avoiding the Console if you want to use Unicode characters. There are many issues with trying to get the Console to display Unicode correctly.
Unicode is not directly supported in Console output. The best option is typically to set the console's code page, which will require P/Invoke.
That being said, a GUI solves all of these issues, in a much nicer fashion. If you need Unicode output, I'd recommend a simple GUI.
You can tell what font is being used by reading the registry value "0" from this key:
HKLM\Software\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont

How do I extract/insert text into RTF string in C#

In a C# console app I have the need to extract the text from an RTF string, add some more text to it, and then convert it back into RTF. I have been able to do this using the System.Windows.Forms.RichTextBox class, but I find it a bit odd to use a Forms control in a non-Forms app. Any better way to do this?
Doing anything with RTF is pretty difficult unless you're using the windows forms. As stated above, using forms is the easiest way to go.
You could write something yourself, but the RTF spec is pretty complicated.
http://www.biblioscape.com/rtf15_spec.htm
Or you could use a conversion DLL / ActiveX object of which there is a large number available.
http://www.sautinsoft.com/
Or - If you're doing this from Linux, there are also tools available. A cursory glance throws up UnRTF
http://www.gnu.org/software/unrtf/unrtf.html
I haven't included stuff to turn text back to RTF because I think the RTF specification treats and formats text correctly.
I think you should just shake this feeling of "odd". There's nothing odd about it.
It depends on what you mean by 'better'. You are already using the simplest and easiest way of doing it.
There is nothing wrong with using an user-interface control in a console application or even in a web application. The Windows controls are part of the .NET Framework, might as well use them. These controls do not need to be hosted in "forms" in order to work.
Reinventing the wheel, using DLL/ActiveX/OCX, and using Linux are simply not practical answers to your question. The better way is...do what you know. There is actually a performance and maintainence benefit to using existing framework methods then using the suggested alternatives.

Categories