The process of converting the logic of some source code from its original language/framework to a different language/framework. Not to be confused with porting, which deals with architectures/platforms.
Questions tagged [code-conversion]
272 questions
1
vote
1 answer
The equivalents of abc.Sequence in Python 2
I need to convert to some Python 3 code to Python 2 code
from collections.abc import Sequence
def to_tensor(X, device):
.....
if isinstance(X, (list, tuple)):
return [to_tensor_(x) for x in X]
if…

Alex Luya
- 9,412
- 15
- 59
- 91
1
vote
1 answer
Porting json response in Ruby to Python
Hey I made a program that takes advantage of a JSON API response in Ruby and I'd like to port it to python, but I don't really know how
JSON response:
{
"Class": {
"Id": 1948237,
"family": "nature",
"Timestamp": 941439
…

Tom
- 571
- 2
- 11
- 29
1
vote
3 answers
Converting C# to VB: New... With {Read-Only Property}
In trying to convert the following C# code from a tutorial (by hand, since cross-compilers I have tried don't seem to be able to do this):
httpClient = new HttpClient(unrelated args)
{
DefaultRequestHeaders =
{
Accept = {…

Trevortni
- 688
- 8
- 23
1
vote
2 answers
Converting Deterministic Path Code from C# to C++
Does anyone know how I can convert this (from C#) to C++?
string location = Path.GetDirectoryName(Assembly.GetAssembly(typeof(ZigbeeCommUSB)).CodeBase);
location = location.Substring(location.IndexOf("\\") + 1);
Thanks.
EDIT: Additional…

Jim Fell
- 13,750
- 36
- 127
- 202
1
vote
0 answers
iOS Bridge for Window Phone crash on addSubview
I'm using Microsoft iOS Bridge to convert an app from iOS to Windows Phone, but UIKit.dll crash when I try to add a View on the Windows object of the AppDelegate.
[self.window addSubview: webView];//UIKIT.dll crash: Access violation reading location…

christian mini
- 1,662
- 20
- 39
1
vote
1 answer
Convert C++ function to MIPS
If you are given:
calc (int b) {
return b - 2;
}
How would it be converted to MIPS?
I've considered the following:
addi $v0, $a0, -2
jr $ra
***********************
jr $ra
addi $v0, $a0, -2
***********************
addi $v0, $a0, 2
jr $ra…
user8588899
1
vote
3 answers
C to C# code conversion - arrays as parameters
I'm stuck on a recursive function in the C code (I did not write the C code). Here is the snippet I'm converting:
int makeroad(float x1, float y1, float x2, float y2, float var, float X[], float Y[], float…

Eric
- 13
- 2
1
vote
2 answers
Is there a way to specify multiple formats in C# for a decimal string like in VB?
I am translating some code from VB to C# and came across this:
Format(seg.R, " 00.00000;-00.00000") // <-- There is a leading space in the first format string
...which prints...
00.00000 //or...
-00.00000
...depending on whether the decimal is…

Mike Webb
- 8,855
- 18
- 78
- 111
1
vote
1 answer
How to Create Digital Signature and Verify it in C# using PKCS 7 and SHA algorithm
I am trying to digitally sign xml document and verify the signature with the original xml file with public key and signed document. I have a java code for reference. I need to convert java code to C# where I have java code like this:
certList =…

Iswar
- 2,211
- 11
- 40
- 65
1
vote
1 answer
Cocoa Async Socket Tutorial Code Conversion from Swift 2 to Swift 3
I am working through a Swift 2 Cocoa Async Socket tutorial which was downloaded from https://github.com/nickyhuyskens/SwiftCocoaAsyncSocketTutorial It was written in Swift 2 and I am working with Xcode 8 / Swift 3. The conversion seem fairly good…

FlapJack
- 11
- 4
1
vote
0 answers
how to traverse xsd with its childs and format using python
I have a requirement to get a report of a large list of XSDs, listing the complexType, minOccurs, maxOccurs, nillable, restrictions, enum values in tabular format. In essence its like transforming the xsd defination in a tabular format. My XSDs are…

kovthe
- 41
- 6
1
vote
2 answers
Convert typedef to Swift
How do I convert this code to Swift
typedef UIViewController CalendarViewController;
tried to find solution everywhere but seems I can't find a reference to this.

Thanh
- 65
- 2
- 10
1
vote
4 answers
Powershell to executable .bat
I'm trying to get the script below, which is in Powershell, converted to an executable .bat file. The basic idea is that I have a bunch of files of which the file name exists out of 3 parts:
Part 1: TKSYSTEMID
Part 2: Variable name
Part 3: YYYY MM…

Priscilla Dimitriou
- 13
- 3
1
vote
0 answers
C++ Builder Header and Code to Delphi
I am trying to convert some C++ Builder code to Delphi and I ran into some uncertainties if the code is actually correct. I would appreciate an expert eye on areas where I should be correcting in case I have made a mistake. This is also a learning…

AndyC
- 31
- 4
1
vote
2 answers
Indicator converted from MQL4 to C# almost done, need help making it fully work (1 out of 2 Outputs stuck in code somewhere)
I've converted the AFIRMA indicator from MQL4 to C#. It outputs the first series correctly (FIRMA) but the second one is stuck somewhere in the code (ARMA). Any ideas where or what keeps it from outputting? It seems like it's stuck somewhere.
Thank…

Ryan J. M.
- 19
- 3