Search the Community
Showing results for tags 'unicode'.
Found 6 results
-
I am converting all my internet support code to use native TNetHttpClient and TNetHttpRequest components. I am getting the exception "No mapping for the Unicode character exists in the target multi-byte code page" for some web pages I am downloading using the function shown below. Here is an instance where the exception occur: GetText('https://www.google.com/index.html'); I assume this is an encoding issue. What is the best way to handle this to get my string result? function TIndigoHttp.GetText (const p_Url: String): String; var v_Response: IHTTPResponse; begin f_Error := ''; // Used by OnRequestError try v_Response := f_NetHTTPRequest.Get(p_Url); f_StatusCode := v_Response.StatusCode; f_StatusText := v_Response.StatusText; Result := v_Response.ContentAsString; except on E: Exception do with v_Response do begin begin Result := ''; f_StatusCode := -1*v_Response.StatusCode; f_StatusText := E.Message+' ['+v_Response.StatusText+']'; end; end; end; end;
- 5 replies
-
- tnethttprequest
- delphi
-
(and 1 more)
Tagged with:
-
I created a Datasnap server application that connects to the MSSQL database via the TFDConnection object, and then executes a specific SQL query via the TFDQuery object, the results of which are further forwarded via the TDataSnapProvider object. This is screenshot of that application I created a simple client application that opens this query and displays the results in a ListBox. This is the code : When I run application on Windows I get a correct result with Serbian letters as you can see in the image below But when U start the same application on Android, I have a problem with display of Serbian letters. What is the problem? Thanks
-
Dllama, a simple and easy to use library for doing local LLM inference directly from Delphi (any language with bindings). It can load GGUF formatted LLMs into CPU or GPU memory. Uses Vulkan back end for acceleration. Simple Example uses System.SysUtils, Dllama, Dllama.Ext; var LResponse: string; LTokenInputSpeed: Single; LTokenOutputSpeed: Single; LInputTokens: Integer; LOutputTokens: Integer; LTotalTokens: Integer; begin // init config Dllama_InitConfig('C:\LLM\gguf', -1, False, VK_ESCAPE); // add model Dllama_AddModel('Meta-Llama-3-8B-Instruct-Q6_K', 'llama3', 1024*8, '<|start_header_id|>%s %s<|end_header_id|>', '\n assistant:\n', ['<|eot_id|>', 'assistant']); // add messages Dllama_AddMessage(ROLE_SYSTEM, 'you are Dllama, a helpful AI assistant.'); Dllama_AddMessage(ROLE_USER, 'who are you?'); // display the user prompt Dllama_Console_PrintLn(Dllama_GetLastUserMessage(), [], DARKGREEN); // do inference if Dllama_Inference('llama3', LResponse) then begin // display usage Dllama_Console_PrintLn(CRLF, [], WHITE); Dllama_GetInferenceUsage(@LTokenInputSpeed, @LTokenOutputSpeed, @LInputTokens, @LOutputTokens, @LTotalTokens); Dllama_Console_PrintLn('Tokens :: Input: %d, Output: %d, Total: %d, Speed: %3.1f t/s', [LInputTokens, LOutputTokens, LTotalTokens, LTokenOutputSpeed], BRIGHTYELLOW); end else begin Dllama_Console_PrintLn('Error: %s', [Dllama_GetError()], RED); end; Dllama_UnloadModel(); end.
-
Delphi - Data is not encoded in given format
Hrushikesh Shet posted a topic in RTL and Delphi Object Pascal
In my Delphi application (Embarcadero RAD Studio 10.0 Seattle), I am trying to convert an rvf file to HTML using TJvRichEdit and TJvRichEditToHtml components. The issue I am facing is that the HTML file appears in ANSI encoding format. I need to get it in UTF-8 format to display the proper content in html file. I have tried the following ways to achieve the same: Tried to use the available properties of TJvRichEdit for converting ANSI to UTF-8. Tried to add the rtf file to TStrings and then used UTF8Encode to convert it. Tried to add data into TMemoryStream and then tried adding it to TJvRichEdit. Used TStreamReader to get the encoding format of the source file and then used TStreamWriter to convert it into UTF-8 encoding. All the above ways convert the encoding format but the content remains in ANSI format. I have also tried using TRichEdit, TcxRichEdit and TdxRichEditControl to find out if we can load data into html file. But the data gets loaded in ANSI encoding format itself. Any help would be appreciated. -
Hi All, Delphi Sydney 10.4.1 I have a Combobox with items. One of those items reads "Tea & Coffee". The Ampersand is seen as an acceleration character, so it disappears and the next space is underlined: Tea _Coffee. Nice on Windows, but not very useful on mobile. Now I can replace the & by && to have it displayed normally, but when a combobox is tapped, iOS takes over and displays the items in a scrollable list at the bottom, now showing "Tea && Coffee" Okay, now trying to stringreplace the & by chr(65286), the unicode full-width ampersand or by chr(65120), the half width ampersand, so it's not recognized as an acceleration character. Looks okay in Windows, but shows the & lowered on Android and much lowered on iOS when used in a fmx-label or a fmx combobox. Is there a way to make such a unicode fullwidth ampersand line up with the other characters in a string? Or, if not, is there a (global) way to completely disable the acceleration character in all labels, combo's etc where the & needs to be displayed? Thanks in advance! John
-
Hi, I moving my project from D2007 to Rio. My project uses ElevateSoftware DBISAM database engine. I was very happy with it but it's not support unicode and I got problems with saving string data from new unicode-enabled delphi controls to TDBISAMTable: i got ???? instead of unicode symbols. I can handle this problem by manually encode/decode string fields values to/from UTF8. But I need to do it in several thousands places in my code :(((( Maybe somebody already found elegant solution for this problem ? Maybe overriding some methods in TDataSet ? I found TStringField.Transliterate and TDataSet.Translate it's almost that I need but function function TDataSet.Translate(Src, Dest: PAnsiChar; ToOem: Boolean): Integer; have PAnsiChar params and I have data loss (???? instead of unicode) here, so I can't use it for background UTF8 conversions. But I need something similar ! Thanks for help !